-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpaging.ts
More file actions
91 lines (83 loc) · 2.09 KB
/
paging.ts
File metadata and controls
91 lines (83 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Wire up directly with Keycloak and use the Services
To run:
npm run ts-build
npm run ts-watch
node dist/test/integrated/batchworker/paging.js
*/
import InitKeystone from '../keystonejs/init';
import {
getRecords,
parseJsonString,
transformAllRefID,
removeEmpty,
removeKeys,
syncRecords,
} from '../../../batch/feed-worker';
import { o } from '../util';
import { BatchService } from '../../../services/keystone/batch-service';
import { newEnvironmentID, newProductID } from '../../../services/identifiers';
(async () => {
const keystone = await InitKeystone();
console.log('K = ' + keystone);
const ns = 'platform';
const skipAccessControl = false;
const identity = {
id: null,
username: 'sample_username',
namespace: ns,
roles: JSON.stringify(['api-owner']),
scopes: [],
userId: null,
} as any;
const ctx = keystone.createContext({
skipAccessControl,
authentication: { item: identity },
});
if (false) {
const json = {
name: 'Refactor Time Test2',
namespace: ns,
environments: [
{
name: 'stage',
appId: '0A021EB0',
//services: [] as any,
//services: ['a-service-for-refactortime'],
// services: ['a-service-for-refactortime', 'a-service-for-aps-moh-proto'],
},
] as any,
};
const res = await syncRecords(ctx, 'Product', null, json);
o(res);
}
if (false) {
for (let i = 0; i < 1000; i++) {
const appId = newProductID();
console.log(appId);
const json = {
name: 'Refactor Time Test 4',
appId: appId,
namespace: ns,
environments: [
{
name: 'stage',
appId: newEnvironmentID(),
services: [] as any,
},
],
};
const res = await syncRecords(ctx, 'Product', appId, json);
o(res);
}
}
const batchService = new BatchService(ctx);
const res = await batchService.listAllPages('allProducts', [
'name',
'namespace',
'dataset { title }',
'createdAt',
]);
//console.log(res);
await keystone.disconnect();
})();