@toolproof-core/lib 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/firebase/firebaseAdminHelpers.d.ts.map +1 -1
- package/dist/firebase/firebaseAdminHelpers.js +10 -4
- package/dist/firebase/firebaseAdminHelpers.js.map +1 -1
- package/package.json +41 -40
- package/src/_lib/setup/firebaseAdminInit.ts +38 -38
- package/src/artifacts/artifacts.ts +40 -40
- package/src/firebase/firebaseAdminHelpers.ts +157 -157
- package/src/types/types.ts +24 -24
- package/src/utils/creation.ts +26 -26
- package/src/utils/resourceMapExtraction.ts +47 -47
- package/tsconfig.json +14 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/extraction.d.ts +0 -12
- package/dist/utils/extraction.d.ts.map +0 -1
- package/dist/utils/extraction.js +0 -27
- package/dist/utils/extraction.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebaseAdminHelpers.d.ts","sourceRoot":"","sources":["../../src/firebase/firebaseAdminHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,wBAAwB,EACxB,YAAY,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAW/H,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,YAAY,EAAE,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAQvG;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAMvG;AAED,wBAAsB,aAAa,CAC/B,mBAAmB,EAAE,wBAAwB,EAAE,GAChD,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"firebaseAdminHelpers.d.ts","sourceRoot":"","sources":["../../src/firebase/firebaseAdminHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,wBAAwB,EACxB,YAAY,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAW/H,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EAAE,YAAY,EAAE,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAQvG;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAMvG;AAED,wBAAsB,aAAa,CAC/B,mBAAmB,EAAE,wBAAwB,EAAE,GAChD,OAAO,CAAC,WAAW,CAAC,CAsHtB"}
|
|
@@ -114,14 +114,19 @@ export async function listResources(resourceTypeHandles) {
|
|
|
114
114
|
// const resourceTypeHandle = root.resourceTypeHandle; // we already have this
|
|
115
115
|
const resourceRoleHandle = root.creationContext.resourceRoleHandle;
|
|
116
116
|
const jobStepHandle = root.creationContext.jobStepHandle;
|
|
117
|
-
const
|
|
117
|
+
const resourceShellKind = root.resourceShellKind;
|
|
118
|
+
const versionRaw = root.version;
|
|
119
|
+
const version = typeof versionRaw === 'number'
|
|
120
|
+
? versionRaw
|
|
121
|
+
: parseInt(String(versionRaw ?? ''), 10);
|
|
118
122
|
const path = root.path;
|
|
119
123
|
const timestamp = root.timestamp;
|
|
120
124
|
const missing = [
|
|
121
125
|
['identity', identity],
|
|
122
126
|
['resourceRoleHandle', resourceRoleHandle],
|
|
123
127
|
['jobStepHandle', jobStepHandle],
|
|
124
|
-
['
|
|
128
|
+
['resourceShellKind', resourceShellKind],
|
|
129
|
+
['version', Number.isFinite(version) ? String(version) : ''],
|
|
125
130
|
['timestamp', timestamp],
|
|
126
131
|
['path', path],
|
|
127
132
|
].filter(([_, v]) => typeof v !== 'string' || v.length === 0);
|
|
@@ -136,9 +141,10 @@ export async function listResources(resourceTypeHandles) {
|
|
|
136
141
|
resourceRoleHandle,
|
|
137
142
|
jobStepHandle,
|
|
138
143
|
},
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
resourceShellKind,
|
|
145
|
+
version,
|
|
141
146
|
timestamp: timestamp,
|
|
147
|
+
path: path,
|
|
142
148
|
nucleus: data,
|
|
143
149
|
};
|
|
144
150
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebaseAdminHelpers.js","sourceRoot":"","sources":["../../src/firebase/firebaseAdminHelpers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAG3E,SAAS,eAAe,CAAC,KAAa;IAClC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,cAAc,CAAyB,YAAe;IAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,OAAO;SACjB,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC;SACvD,GAAG,CAAC,YAAY,CAAC;SACjB,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC;SACrD,GAAG,EAAE,CAAC;IACX,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAoC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAyB,QAAW;IAClE,MAAM,YAAY,GAAG,GAAG,eAAe,CAAC,QAAQ,CA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
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"packageManager": "pnpm@10.15.0",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"build": "tsc -b"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
"exports": {
|
|
15
|
+
"./artifacts": {
|
|
16
|
+
"types": "./dist/artifacts/artifacts.d.ts",
|
|
17
|
+
"import": "./dist/artifacts/artifacts.js"
|
|
18
|
+
},
|
|
19
|
+
"./types": {
|
|
20
|
+
"types": "./dist/types/types.d.ts",
|
|
21
|
+
"import": "./dist/types/types.js"
|
|
22
|
+
},
|
|
23
|
+
"./resource-map-extraction": {
|
|
24
|
+
"types": "./dist/utils/resourceMapExtraction.d.ts",
|
|
25
|
+
"import": "./dist/utils/resourceMapExtraction.js"
|
|
26
|
+
},
|
|
27
|
+
"./creation": {
|
|
28
|
+
"types": "./dist/utils/creation.d.ts",
|
|
29
|
+
"import": "./dist/utils/creation.js"
|
|
30
|
+
},
|
|
31
|
+
"./firebase-admin-init": {
|
|
32
|
+
"types": "./dist/_lib/setup/firebaseAdminInit.d.ts",
|
|
33
|
+
"import": "./dist/_lib/setup/firebaseAdminInit.js"
|
|
34
|
+
},
|
|
35
|
+
"./firebase-admin-helpers": {
|
|
36
|
+
"types": "./dist/firebase/firebaseAdminHelpers.d.ts",
|
|
37
|
+
"import": "./dist/firebase/firebaseAdminHelpers.js"
|
|
38
|
+
}
|
|
17
39
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"import": "./dist/utils/resourceMapExtraction.js"
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.0.0"
|
|
21
42
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
"./firebase-admin-init": {
|
|
27
|
-
"types": "./dist/_lib/setup/firebaseAdminInit.d.ts",
|
|
28
|
-
"import": "./dist/_lib/setup/firebaseAdminInit.js"
|
|
29
|
-
},
|
|
30
|
-
"./firebase-admin-helpers": {
|
|
31
|
-
"types": "./dist/firebase/firebaseAdminHelpers.d.ts",
|
|
32
|
-
"import": "./dist/firebase/firebaseAdminHelpers.js"
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@toolproof-core/schema": "workspace:*",
|
|
45
|
+
"firebase-admin": "^13.7.0"
|
|
33
46
|
}
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@types/node": "^22.0.0"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"firebase-admin": "^13.7.0",
|
|
40
|
-
"@toolproof-core/schema": "1.0.10"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
44
|
-
"build": "tsc -b"
|
|
45
|
-
}
|
|
46
47
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { getApp, getApps, initializeApp, applicationDefault, cert } from 'firebase-admin/app';
|
|
2
|
-
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
-
import { getStorage } from 'firebase-admin/storage';
|
|
4
|
-
import { existsSync, readFileSync } from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
|
|
7
|
-
// Resolve credentials: prefer GOOGLE_APPLICATION_CREDENTIALS, fallback to local gcp-key.json, else ADC
|
|
8
|
-
function resolveCredential() {
|
|
9
|
-
const jsonString = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON;
|
|
10
|
-
const envPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
11
|
-
const localKeyPath = path.join(process.cwd(), 'gcp-key.json');
|
|
12
|
-
try {
|
|
13
|
-
if (jsonString) {
|
|
14
|
-
const json = JSON.parse(jsonString);
|
|
15
|
-
return cert(json);
|
|
16
|
-
}
|
|
17
|
-
if (envPath && existsSync(envPath)) {
|
|
18
|
-
const json = JSON.parse(readFileSync(envPath, 'utf8'));
|
|
19
|
-
return cert(json);
|
|
20
|
-
}
|
|
21
|
-
if (existsSync(localKeyPath)) {
|
|
22
|
-
const json = JSON.parse(readFileSync(localKeyPath, 'utf8'));
|
|
23
|
-
return cert(json);
|
|
24
|
-
}
|
|
25
|
-
} catch {
|
|
26
|
-
// fall through to ADC
|
|
27
|
-
}
|
|
28
|
-
return applicationDefault();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const app = getApps().length ? getApp() : initializeApp({
|
|
32
|
-
credential: resolveCredential(),
|
|
33
|
-
projectId: "toolproof-563fe",
|
|
34
|
-
});
|
|
35
|
-
const dbAdmin = getFirestore(app);
|
|
36
|
-
const storageAdmin = getStorage(app);
|
|
37
|
-
|
|
38
|
-
export { dbAdmin, storageAdmin };
|
|
1
|
+
import { getApp, getApps, initializeApp, applicationDefault, cert } from 'firebase-admin/app';
|
|
2
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
3
|
+
import { getStorage } from 'firebase-admin/storage';
|
|
4
|
+
import { existsSync, readFileSync } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
// Resolve credentials: prefer GOOGLE_APPLICATION_CREDENTIALS, fallback to local gcp-key.json, else ADC
|
|
8
|
+
function resolveCredential() {
|
|
9
|
+
const jsonString = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON;
|
|
10
|
+
const envPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
11
|
+
const localKeyPath = path.join(process.cwd(), 'gcp-key.json');
|
|
12
|
+
try {
|
|
13
|
+
if (jsonString) {
|
|
14
|
+
const json = JSON.parse(jsonString);
|
|
15
|
+
return cert(json);
|
|
16
|
+
}
|
|
17
|
+
if (envPath && existsSync(envPath)) {
|
|
18
|
+
const json = JSON.parse(readFileSync(envPath, 'utf8'));
|
|
19
|
+
return cert(json);
|
|
20
|
+
}
|
|
21
|
+
if (existsSync(localKeyPath)) {
|
|
22
|
+
const json = JSON.parse(readFileSync(localKeyPath, 'utf8'));
|
|
23
|
+
return cert(json);
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
// fall through to ADC
|
|
27
|
+
}
|
|
28
|
+
return applicationDefault();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const app = getApps().length ? getApp() : initializeApp({
|
|
32
|
+
credential: resolveCredential(),
|
|
33
|
+
projectId: "toolproof-563fe",
|
|
34
|
+
});
|
|
35
|
+
const dbAdmin = getFirestore(app);
|
|
36
|
+
const storageAdmin = getStorage(app);
|
|
37
|
+
|
|
38
|
+
export { dbAdmin, storageAdmin };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { CONSTANTS as _CONSTANTS, MAPPINGS as _MAPPINGS } from "@toolproof-core/schema";
|
|
2
|
-
|
|
3
|
-
export const CONSTANTS = {
|
|
4
|
-
..._CONSTANTS,
|
|
5
|
-
Persistence: {
|
|
6
|
-
Buckets: {
|
|
7
|
-
tp_resources: 'tp-resources',
|
|
8
|
-
tp_strategies: 'tp-strategies',
|
|
9
|
-
},
|
|
10
|
-
Collections: {
|
|
11
|
-
resources: 'resources',
|
|
12
|
-
members: 'members',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
Engine: {
|
|
16
|
-
Graphs: {
|
|
17
|
-
GraphRunStrategy: 'GraphRunStrategy',
|
|
18
|
-
GraphBuildStrategy: 'GraphBuildStrategy',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
Cosmos: {
|
|
22
|
-
TYPE_Boolean: 'TYPE-Boolean',
|
|
23
|
-
TYPE_Natural: 'TYPE-Natural',
|
|
24
|
-
TYPE_ResourceType: 'TYPE-ResourceType',
|
|
25
|
-
TYPE_Job: 'TYPE-Job',
|
|
26
|
-
TYPE_Error: 'TYPE-Error',
|
|
27
|
-
TYPE_RawStrategy: 'TYPE-RawStrategy',
|
|
28
|
-
TYPE_RunnableStrategy: 'TYPE-RunnableStrategy',
|
|
29
|
-
TYPE_StrategyRun: 'TYPE-StrategyRun',
|
|
30
|
-
ROLE_Manual: 'ROLE-Manual',
|
|
31
|
-
ROLE_ErrorOutput: 'ROLE-ErrorOutput',
|
|
32
|
-
ROLE_LessThanSource: 'ROLE-LessThanSource',
|
|
33
|
-
ROLE_LessThanTarget: 'ROLE-LessThanTarget',
|
|
34
|
-
ROLE_LessThanDecision: 'ROLE-LessThanDecision',
|
|
35
|
-
JOB_LessThan: 'JOB-LessThan',
|
|
36
|
-
}
|
|
37
|
-
} as const;
|
|
38
|
-
|
|
39
|
-
export const MAPPINGS = {
|
|
40
|
-
..._MAPPINGS,
|
|
1
|
+
import { CONSTANTS as _CONSTANTS, MAPPINGS as _MAPPINGS } from "@toolproof-core/schema";
|
|
2
|
+
|
|
3
|
+
export const CONSTANTS = {
|
|
4
|
+
..._CONSTANTS,
|
|
5
|
+
Persistence: {
|
|
6
|
+
Buckets: {
|
|
7
|
+
tp_resources: 'tp-resources',
|
|
8
|
+
tp_strategies: 'tp-strategies',
|
|
9
|
+
},
|
|
10
|
+
Collections: {
|
|
11
|
+
resources: 'resources',
|
|
12
|
+
members: 'members',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
Engine: {
|
|
16
|
+
Graphs: {
|
|
17
|
+
GraphRunStrategy: 'GraphRunStrategy',
|
|
18
|
+
GraphBuildStrategy: 'GraphBuildStrategy',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
Cosmos: {
|
|
22
|
+
TYPE_Boolean: 'TYPE-Boolean',
|
|
23
|
+
TYPE_Natural: 'TYPE-Natural',
|
|
24
|
+
TYPE_ResourceType: 'TYPE-ResourceType',
|
|
25
|
+
TYPE_Job: 'TYPE-Job',
|
|
26
|
+
TYPE_Error: 'TYPE-Error',
|
|
27
|
+
TYPE_RawStrategy: 'TYPE-RawStrategy',
|
|
28
|
+
TYPE_RunnableStrategy: 'TYPE-RunnableStrategy',
|
|
29
|
+
TYPE_StrategyRun: 'TYPE-StrategyRun',
|
|
30
|
+
ROLE_Manual: 'ROLE-Manual',
|
|
31
|
+
ROLE_ErrorOutput: 'ROLE-ErrorOutput',
|
|
32
|
+
ROLE_LessThanSource: 'ROLE-LessThanSource',
|
|
33
|
+
ROLE_LessThanTarget: 'ROLE-LessThanTarget',
|
|
34
|
+
ROLE_LessThanDecision: 'ROLE-LessThanDecision',
|
|
35
|
+
JOB_LessThan: 'JOB-LessThan',
|
|
36
|
+
}
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
export const MAPPINGS = {
|
|
40
|
+
..._MAPPINGS,
|
|
41
41
|
} as const;
|
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ResourceJson,
|
|
3
|
-
ResourceTypeIdentityJson,
|
|
4
|
-
StepKindJson,
|
|
5
|
-
} from '@toolproof-core/schema';
|
|
6
|
-
import type { IdentityName, IdentityStringByIdentityName, StepIdentityStringByStepKind, ResourceMap } from '../types/types.js';
|
|
7
|
-
import { CONSTANTS } from '../artifacts/artifacts.js';
|
|
8
|
-
import { MAPPINGS } from '../artifacts/artifacts.js';
|
|
9
|
-
import { dbAdmin, storageAdmin } from "../_lib/setup/firebaseAdminInit.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function capitalizeFirst(value: string): string {
|
|
13
|
-
if (!value) return value;
|
|
14
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getNewIdentity<K extends IdentityName>(identityName: K): IdentityStringByIdentityName<K> {
|
|
18
|
-
const prefix = MAPPINGS.IdentityNameToIdentityPrefix[identityName];
|
|
19
|
-
const docRef = dbAdmin
|
|
20
|
-
.collection(CONSTANTS.Persistence.Collections.resources)
|
|
21
|
-
.doc(identityName)
|
|
22
|
-
.collection(CONSTANTS.Persistence.Collections.members)
|
|
23
|
-
.doc();
|
|
24
|
-
return (prefix + docRef.id) as IdentityStringByIdentityName<K>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function getNewStepIdentity<K extends StepKindJson>(stepKind: K): StepIdentityStringByStepKind<K> {
|
|
28
|
-
const identityName = `${capitalizeFirst(stepKind)}StepIdentity` as IdentityName;
|
|
29
|
-
if (!(identityName in MAPPINGS.IdentityNameToIdentityPrefix)) {
|
|
30
|
-
throw new Error(`No IdentityNameToIdentityPrefix entry for derived step identity name: ${identityName}`);
|
|
31
|
-
}
|
|
32
|
-
return getNewIdentity(identityName) as StepIdentityStringByStepKind<K>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function listResources(
|
|
36
|
-
resourceTypeHandles: ResourceTypeIdentityJson[]
|
|
37
|
-
): Promise<ResourceMap> {
|
|
38
|
-
const bucket_resources = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_resources);
|
|
39
|
-
const bucket_strategies = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_strategies);
|
|
40
|
-
|
|
41
|
-
async function fetchFilesUnder(resourceTypeHandle: ResourceTypeIdentityJson): Promise<Array<{ data: unknown; meta: any; name: string }>> {
|
|
42
|
-
const bucket = resourceTypeHandle === CONSTANTS.Cosmos.TYPE_RunnableStrategy
|
|
43
|
-
? bucket_strategies
|
|
44
|
-
: bucket_resources;
|
|
45
|
-
const prefix = `${resourceTypeHandle}/`;
|
|
46
|
-
const [found] = await bucket.getFiles({ prefix });
|
|
47
|
-
const files = found.filter(f => {
|
|
48
|
-
const name = f.name || '';
|
|
49
|
-
if (!name || name.endsWith('/')) return false;
|
|
50
|
-
return true;
|
|
51
|
-
});
|
|
52
|
-
if (!files.length) return [];
|
|
53
|
-
const items = await Promise.all(files.map(async (file) => {
|
|
54
|
-
try {
|
|
55
|
-
const [buf] = await file.download();
|
|
56
|
-
const meta = file.metadata || (await file.getMetadata())[0];
|
|
57
|
-
const data = JSON.parse(buf.toString('utf8')) as unknown;
|
|
58
|
-
return { data, meta, name: file.name };
|
|
59
|
-
} catch {
|
|
60
|
-
return null as unknown as { data: unknown; meta: any; name: string };
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
return items.filter(Boolean) as Array<{ data: unknown; meta: any; name: string }>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const entries = await Promise.all(
|
|
67
|
-
resourceTypeHandles.map(async (resourceTypeHandle) => {
|
|
68
|
-
const rows = await fetchFilesUnder(resourceTypeHandle);
|
|
69
|
-
const items: ResourceJson[] = rows.map(({ data, meta, name }) => {
|
|
70
|
-
const flat = meta?.metadata ?? {};
|
|
71
|
-
// Reconstruct nested object from flattened keys (dot and array index notation)
|
|
72
|
-
const root: any = {};
|
|
73
|
-
for (const [k, vRaw] of Object.entries(flat)) {
|
|
74
|
-
if (typeof vRaw !== 'string') continue; // GCS should store only strings
|
|
75
|
-
const vStr = vRaw.trim();
|
|
76
|
-
// Attempt JSON parse for non-simple primitives
|
|
77
|
-
let value: any = vStr;
|
|
78
|
-
if ((vStr.startsWith('{') && vStr.endsWith('}')) || (vStr.startsWith('[') && vStr.endsWith(']'))) {
|
|
79
|
-
try { value = JSON.parse(vStr); } catch { value = vStr; }
|
|
80
|
-
}
|
|
81
|
-
// Split by '.' while preserving array indices
|
|
82
|
-
const segments = k.split('.');
|
|
83
|
-
let cursor = root;
|
|
84
|
-
for (const [i, seg] of segments.entries()) {
|
|
85
|
-
const arrIdxMatch = seg.match(/^(.*)\[(\d+)\]$/);
|
|
86
|
-
if (arrIdxMatch) {
|
|
87
|
-
const base = arrIdxMatch[1];
|
|
88
|
-
const idxStr = arrIdxMatch[2];
|
|
89
|
-
if (base === undefined || idxStr === undefined) continue;
|
|
90
|
-
const idx = parseInt(idxStr, 10);
|
|
91
|
-
if (!cursor[base]) cursor[base] = [];
|
|
92
|
-
if (!Array.isArray(cursor[base])) cursor[base] = [];
|
|
93
|
-
while (cursor[base].length <= idx) cursor[base].push(undefined);
|
|
94
|
-
if (i === segments.length - 1) {
|
|
95
|
-
cursor[base][idx] = value;
|
|
96
|
-
} else {
|
|
97
|
-
if (!cursor[base][idx]) cursor[base][idx] = {};
|
|
98
|
-
cursor = cursor[base][idx];
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
if (i === segments.length - 1) {
|
|
102
|
-
cursor[seg] = value;
|
|
103
|
-
} else {
|
|
104
|
-
if (!cursor[seg] || typeof cursor[seg] !== 'object') cursor[seg] = {};
|
|
105
|
-
cursor = cursor[seg];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const identity = root.identity;
|
|
111
|
-
// const resourceTypeHandle = root.resourceTypeHandle; // we already have this
|
|
112
|
-
const resourceRoleHandle = root.creationContext.resourceRoleHandle;
|
|
113
|
-
const jobStepHandle = root.creationContext.jobStepHandle;
|
|
114
|
-
const resourceShellKind = root.resourceShellKind;
|
|
115
|
-
const versionRaw = root.version;
|
|
116
|
-
const version = typeof versionRaw === 'number'
|
|
117
|
-
? versionRaw
|
|
118
|
-
: parseInt(String(versionRaw ?? ''), 10);
|
|
119
|
-
const path = root.path;
|
|
120
|
-
const timestamp = root.timestamp;
|
|
121
|
-
|
|
122
|
-
const missing = [
|
|
123
|
-
['identity', identity],
|
|
124
|
-
['resourceRoleHandle', resourceRoleHandle],
|
|
125
|
-
['jobStepHandle', jobStepHandle],
|
|
126
|
-
['resourceShellKind', resourceShellKind],
|
|
127
|
-
['version', Number.isFinite(version) ? String(version) : ''],
|
|
128
|
-
['timestamp', timestamp],
|
|
129
|
-
['path', path],
|
|
130
|
-
].filter(([_, v]) => typeof v !== 'string' || (v as string).length === 0) as Array<[string, string | undefined]>;
|
|
131
|
-
|
|
132
|
-
if (missing.length) {
|
|
133
|
-
const keys = missing.map(([k]) => k).join(', ');
|
|
134
|
-
throw new Error(`Missing required metadata keys [${keys}] for resource file: ${name}`);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
identity,
|
|
139
|
-
resourceTypeHandle,
|
|
140
|
-
creationContext: {
|
|
141
|
-
resourceRoleHandle,
|
|
142
|
-
jobStepHandle,
|
|
143
|
-
},
|
|
144
|
-
resourceShellKind,
|
|
145
|
-
version,
|
|
146
|
-
timestamp: timestamp as string,
|
|
147
|
-
path: path as string,
|
|
148
|
-
nucleus: data as any,
|
|
149
|
-
} as unknown as ResourceJson;
|
|
150
|
-
});
|
|
151
|
-
return [resourceTypeHandle, items] as const;
|
|
152
|
-
})
|
|
153
|
-
);
|
|
154
|
-
return Object.fromEntries(entries) as ResourceMap;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ResourceJson,
|
|
3
|
+
ResourceTypeIdentityJson,
|
|
4
|
+
StepKindJson,
|
|
5
|
+
} from '@toolproof-core/schema';
|
|
6
|
+
import type { IdentityName, IdentityStringByIdentityName, StepIdentityStringByStepKind, ResourceMap } from '../types/types.js';
|
|
7
|
+
import { CONSTANTS } from '../artifacts/artifacts.js';
|
|
8
|
+
import { MAPPINGS } from '../artifacts/artifacts.js';
|
|
9
|
+
import { dbAdmin, storageAdmin } from "../_lib/setup/firebaseAdminInit.js";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function capitalizeFirst(value: string): string {
|
|
13
|
+
if (!value) return value;
|
|
14
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getNewIdentity<K extends IdentityName>(identityName: K): IdentityStringByIdentityName<K> {
|
|
18
|
+
const prefix = MAPPINGS.IdentityNameToIdentityPrefix[identityName];
|
|
19
|
+
const docRef = dbAdmin
|
|
20
|
+
.collection(CONSTANTS.Persistence.Collections.resources)
|
|
21
|
+
.doc(identityName)
|
|
22
|
+
.collection(CONSTANTS.Persistence.Collections.members)
|
|
23
|
+
.doc();
|
|
24
|
+
return (prefix + docRef.id) as IdentityStringByIdentityName<K>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getNewStepIdentity<K extends StepKindJson>(stepKind: K): StepIdentityStringByStepKind<K> {
|
|
28
|
+
const identityName = `${capitalizeFirst(stepKind)}StepIdentity` as IdentityName;
|
|
29
|
+
if (!(identityName in MAPPINGS.IdentityNameToIdentityPrefix)) {
|
|
30
|
+
throw new Error(`No IdentityNameToIdentityPrefix entry for derived step identity name: ${identityName}`);
|
|
31
|
+
}
|
|
32
|
+
return getNewIdentity(identityName) as StepIdentityStringByStepKind<K>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function listResources(
|
|
36
|
+
resourceTypeHandles: ResourceTypeIdentityJson[]
|
|
37
|
+
): Promise<ResourceMap> {
|
|
38
|
+
const bucket_resources = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_resources);
|
|
39
|
+
const bucket_strategies = storageAdmin.bucket(CONSTANTS.Persistence.Buckets.tp_strategies);
|
|
40
|
+
|
|
41
|
+
async function fetchFilesUnder(resourceTypeHandle: ResourceTypeIdentityJson): Promise<Array<{ data: unknown; meta: any; name: string }>> {
|
|
42
|
+
const bucket = resourceTypeHandle === CONSTANTS.Cosmos.TYPE_RunnableStrategy
|
|
43
|
+
? bucket_strategies
|
|
44
|
+
: bucket_resources;
|
|
45
|
+
const prefix = `${resourceTypeHandle}/`;
|
|
46
|
+
const [found] = await bucket.getFiles({ prefix });
|
|
47
|
+
const files = found.filter(f => {
|
|
48
|
+
const name = f.name || '';
|
|
49
|
+
if (!name || name.endsWith('/')) return false;
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
if (!files.length) return [];
|
|
53
|
+
const items = await Promise.all(files.map(async (file) => {
|
|
54
|
+
try {
|
|
55
|
+
const [buf] = await file.download();
|
|
56
|
+
const meta = file.metadata || (await file.getMetadata())[0];
|
|
57
|
+
const data = JSON.parse(buf.toString('utf8')) as unknown;
|
|
58
|
+
return { data, meta, name: file.name };
|
|
59
|
+
} catch {
|
|
60
|
+
return null as unknown as { data: unknown; meta: any; name: string };
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
return items.filter(Boolean) as Array<{ data: unknown; meta: any; name: string }>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const entries = await Promise.all(
|
|
67
|
+
resourceTypeHandles.map(async (resourceTypeHandle) => {
|
|
68
|
+
const rows = await fetchFilesUnder(resourceTypeHandle);
|
|
69
|
+
const items: ResourceJson[] = rows.map(({ data, meta, name }) => {
|
|
70
|
+
const flat = meta?.metadata ?? {};
|
|
71
|
+
// Reconstruct nested object from flattened keys (dot and array index notation)
|
|
72
|
+
const root: any = {};
|
|
73
|
+
for (const [k, vRaw] of Object.entries(flat)) {
|
|
74
|
+
if (typeof vRaw !== 'string') continue; // GCS should store only strings
|
|
75
|
+
const vStr = vRaw.trim();
|
|
76
|
+
// Attempt JSON parse for non-simple primitives
|
|
77
|
+
let value: any = vStr;
|
|
78
|
+
if ((vStr.startsWith('{') && vStr.endsWith('}')) || (vStr.startsWith('[') && vStr.endsWith(']'))) {
|
|
79
|
+
try { value = JSON.parse(vStr); } catch { value = vStr; }
|
|
80
|
+
}
|
|
81
|
+
// Split by '.' while preserving array indices
|
|
82
|
+
const segments = k.split('.');
|
|
83
|
+
let cursor = root;
|
|
84
|
+
for (const [i, seg] of segments.entries()) {
|
|
85
|
+
const arrIdxMatch = seg.match(/^(.*)\[(\d+)\]$/);
|
|
86
|
+
if (arrIdxMatch) {
|
|
87
|
+
const base = arrIdxMatch[1];
|
|
88
|
+
const idxStr = arrIdxMatch[2];
|
|
89
|
+
if (base === undefined || idxStr === undefined) continue;
|
|
90
|
+
const idx = parseInt(idxStr, 10);
|
|
91
|
+
if (!cursor[base]) cursor[base] = [];
|
|
92
|
+
if (!Array.isArray(cursor[base])) cursor[base] = [];
|
|
93
|
+
while (cursor[base].length <= idx) cursor[base].push(undefined);
|
|
94
|
+
if (i === segments.length - 1) {
|
|
95
|
+
cursor[base][idx] = value;
|
|
96
|
+
} else {
|
|
97
|
+
if (!cursor[base][idx]) cursor[base][idx] = {};
|
|
98
|
+
cursor = cursor[base][idx];
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
if (i === segments.length - 1) {
|
|
102
|
+
cursor[seg] = value;
|
|
103
|
+
} else {
|
|
104
|
+
if (!cursor[seg] || typeof cursor[seg] !== 'object') cursor[seg] = {};
|
|
105
|
+
cursor = cursor[seg];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const identity = root.identity;
|
|
111
|
+
// const resourceTypeHandle = root.resourceTypeHandle; // we already have this
|
|
112
|
+
const resourceRoleHandle = root.creationContext.resourceRoleHandle;
|
|
113
|
+
const jobStepHandle = root.creationContext.jobStepHandle;
|
|
114
|
+
const resourceShellKind = root.resourceShellKind;
|
|
115
|
+
const versionRaw = root.version;
|
|
116
|
+
const version = typeof versionRaw === 'number'
|
|
117
|
+
? versionRaw
|
|
118
|
+
: parseInt(String(versionRaw ?? ''), 10);
|
|
119
|
+
const path = root.path;
|
|
120
|
+
const timestamp = root.timestamp;
|
|
121
|
+
|
|
122
|
+
const missing = [
|
|
123
|
+
['identity', identity],
|
|
124
|
+
['resourceRoleHandle', resourceRoleHandle],
|
|
125
|
+
['jobStepHandle', jobStepHandle],
|
|
126
|
+
['resourceShellKind', resourceShellKind],
|
|
127
|
+
['version', Number.isFinite(version) ? String(version) : ''],
|
|
128
|
+
['timestamp', timestamp],
|
|
129
|
+
['path', path],
|
|
130
|
+
].filter(([_, v]) => typeof v !== 'string' || (v as string).length === 0) as Array<[string, string | undefined]>;
|
|
131
|
+
|
|
132
|
+
if (missing.length) {
|
|
133
|
+
const keys = missing.map(([k]) => k).join(', ');
|
|
134
|
+
throw new Error(`Missing required metadata keys [${keys}] for resource file: ${name}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
identity,
|
|
139
|
+
resourceTypeHandle,
|
|
140
|
+
creationContext: {
|
|
141
|
+
resourceRoleHandle,
|
|
142
|
+
jobStepHandle,
|
|
143
|
+
},
|
|
144
|
+
resourceShellKind,
|
|
145
|
+
version,
|
|
146
|
+
timestamp: timestamp as string,
|
|
147
|
+
path: path as string,
|
|
148
|
+
nucleus: data as any,
|
|
149
|
+
} as unknown as ResourceJson;
|
|
150
|
+
});
|
|
151
|
+
return [resourceTypeHandle, items] as const;
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
return Object.fromEntries(entries) as ResourceMap;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
package/src/types/types.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
StepKindJson,
|
|
3
|
-
ResourceJson,
|
|
4
|
-
ResourceRoleIdentityJson,
|
|
5
|
-
ResourceRoleValueJson,
|
|
6
|
-
ResourceTypeIdentityJson,
|
|
7
|
-
} from '@toolproof-core/schema';
|
|
8
|
-
import { CONSTANTS } from '../artifacts/artifacts.js';
|
|
9
|
-
import { MAPPINGS } from '../artifacts/artifacts.js';
|
|
10
|
-
|
|
11
|
-
export type Bucket = typeof CONSTANTS.Persistence.Buckets.tp_resources;
|
|
12
|
-
|
|
13
|
-
export type Collection = keyof typeof CONSTANTS.Persistence.Collections;
|
|
14
|
-
|
|
15
|
-
export type SchemaLike = Record<string, unknown>;
|
|
16
|
-
|
|
17
|
-
export type Role = { identity: ResourceRoleIdentityJson } & ResourceRoleValueJson;
|
|
18
|
-
|
|
19
|
-
export type ResourceMap = Record<ResourceTypeIdentityJson, ResourceJson[]>;
|
|
20
|
-
|
|
21
|
-
export type IdentityName = keyof typeof MAPPINGS.IdentityNameToIdentityPrefix;
|
|
22
|
-
|
|
23
|
-
export type IdentityStringByIdentityName<K extends IdentityName> = `${(typeof MAPPINGS.IdentityNameToIdentityPrefix)[K]}${string}`;
|
|
24
|
-
|
|
1
|
+
import type {
|
|
2
|
+
StepKindJson,
|
|
3
|
+
ResourceJson,
|
|
4
|
+
ResourceRoleIdentityJson,
|
|
5
|
+
ResourceRoleValueJson,
|
|
6
|
+
ResourceTypeIdentityJson,
|
|
7
|
+
} from '@toolproof-core/schema';
|
|
8
|
+
import { CONSTANTS } from '../artifacts/artifacts.js';
|
|
9
|
+
import { MAPPINGS } from '../artifacts/artifacts.js';
|
|
10
|
+
|
|
11
|
+
export type Bucket = typeof CONSTANTS.Persistence.Buckets.tp_resources;
|
|
12
|
+
|
|
13
|
+
export type Collection = keyof typeof CONSTANTS.Persistence.Collections;
|
|
14
|
+
|
|
15
|
+
export type SchemaLike = Record<string, unknown>;
|
|
16
|
+
|
|
17
|
+
export type Role = { identity: ResourceRoleIdentityJson } & ResourceRoleValueJson;
|
|
18
|
+
|
|
19
|
+
export type ResourceMap = Record<ResourceTypeIdentityJson, ResourceJson[]>;
|
|
20
|
+
|
|
21
|
+
export type IdentityName = keyof typeof MAPPINGS.IdentityNameToIdentityPrefix;
|
|
22
|
+
|
|
23
|
+
export type IdentityStringByIdentityName<K extends IdentityName> = `${(typeof MAPPINGS.IdentityNameToIdentityPrefix)[K]}${string}`;
|
|
24
|
+
|
|
25
25
|
export type StepIdentityStringByStepKind<K extends StepKindJson> = `${(typeof MAPPINGS.StepKindToStepIdentityPrefix)[K]}${string}`;
|
package/src/utils/creation.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { ResourceIdentityJson, ResourceTypeIdentityJson, ResourceJson, ResourceOutputPotentialJson } from '@toolproof-core/schema';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function generatePath(resourceTypeHandle: ResourceTypeIdentityJson, identity: ResourceIdentityJson): string {
|
|
5
|
-
return `${resourceTypeHandle}/${identity}.json`;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function fromOutputPotentialToMaterialized(
|
|
9
|
-
outputPotential: ResourceOutputPotentialJson,
|
|
10
|
-
nucleus: unknown,
|
|
11
|
-
timestamp?: string
|
|
12
|
-
): ResourceJson {
|
|
13
|
-
const { identity, resourceTypeHandle, creationContext } = outputPotential;
|
|
14
|
-
|
|
15
|
-
const path = generatePath(resourceTypeHandle, identity);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
identity,
|
|
19
|
-
resourceTypeHandle,
|
|
20
|
-
creationContext,
|
|
21
|
-
resourceShellKind: 'materialized',
|
|
22
|
-
version: 1,
|
|
23
|
-
timestamp: timestamp ?? new Date().toISOString(), // Preserve original timestamp when copying
|
|
24
|
-
path,
|
|
25
|
-
nucleus,
|
|
26
|
-
};
|
|
1
|
+
import type { ResourceIdentityJson, ResourceTypeIdentityJson, ResourceJson, ResourceOutputPotentialJson } from '@toolproof-core/schema';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function generatePath(resourceTypeHandle: ResourceTypeIdentityJson, identity: ResourceIdentityJson): string {
|
|
5
|
+
return `${resourceTypeHandle}/${identity}.json`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function fromOutputPotentialToMaterialized(
|
|
9
|
+
outputPotential: ResourceOutputPotentialJson,
|
|
10
|
+
nucleus: unknown,
|
|
11
|
+
timestamp?: string
|
|
12
|
+
): ResourceJson {
|
|
13
|
+
const { identity, resourceTypeHandle, creationContext } = outputPotential;
|
|
14
|
+
|
|
15
|
+
const path = generatePath(resourceTypeHandle, identity);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
identity,
|
|
19
|
+
resourceTypeHandle,
|
|
20
|
+
creationContext,
|
|
21
|
+
resourceShellKind: 'materialized',
|
|
22
|
+
version: 1,
|
|
23
|
+
timestamp: timestamp ?? new Date().toISOString(), // Preserve original timestamp when copying
|
|
24
|
+
path,
|
|
25
|
+
nucleus,
|
|
26
|
+
};
|
|
27
27
|
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ResourceIdentityJson,
|
|
3
|
-
ResourceTypeIdentityJson,
|
|
4
|
-
ResourceJson,
|
|
5
|
-
} from '@toolproof-core/schema';
|
|
6
|
-
import type { ResourceMap } from '../types/types.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function extractResourcesByType<TResource extends ResourceJson = ResourceJson>(
|
|
10
|
-
resourceMap: ResourceMap,
|
|
11
|
-
resourceTypeHandle: ResourceTypeIdentityJson
|
|
12
|
-
): Record<ResourceIdentityJson, TResource> {
|
|
13
|
-
const resources = (resourceMap[resourceTypeHandle] ?? []) as TResource[];
|
|
14
|
-
const result: Record<ResourceIdentityJson, TResource> = {} as Record<ResourceIdentityJson, TResource>;
|
|
15
|
-
|
|
16
|
-
for (const resource of resources) {
|
|
17
|
-
result[resource.identity] = resource;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
export function extractNucleusMap<
|
|
27
|
-
TKey extends string = string,
|
|
28
|
-
TNucleus extends { identity: string | number | boolean } = { identity: string | number | boolean },
|
|
29
|
-
TResource extends ResourceJson = ResourceJson
|
|
30
|
-
>(
|
|
31
|
-
resourceMap: ResourceMap,
|
|
32
|
-
resourceTypeHandle: ResourceTypeIdentityJson,
|
|
33
|
-
): Map<TKey, TNucleus> {
|
|
34
|
-
const resources = extractResourcesByType<TResource>(resourceMap, resourceTypeHandle);
|
|
35
|
-
const out = new Map<TKey, TNucleus>();
|
|
36
|
-
|
|
37
|
-
for (const resource of Object.values(resources)) {
|
|
38
|
-
const data = (resource as any).nucleus as unknown;
|
|
39
|
-
|
|
40
|
-
const value = data as TNucleus;
|
|
41
|
-
const key = String(value.identity) as TKey;
|
|
42
|
-
|
|
43
|
-
out.set(key, value);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return out;
|
|
47
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
ResourceIdentityJson,
|
|
3
|
+
ResourceTypeIdentityJson,
|
|
4
|
+
ResourceJson,
|
|
5
|
+
} from '@toolproof-core/schema';
|
|
6
|
+
import type { ResourceMap } from '../types/types.js';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function extractResourcesByType<TResource extends ResourceJson = ResourceJson>(
|
|
10
|
+
resourceMap: ResourceMap,
|
|
11
|
+
resourceTypeHandle: ResourceTypeIdentityJson
|
|
12
|
+
): Record<ResourceIdentityJson, TResource> {
|
|
13
|
+
const resources = (resourceMap[resourceTypeHandle] ?? []) as TResource[];
|
|
14
|
+
const result: Record<ResourceIdentityJson, TResource> = {} as Record<ResourceIdentityJson, TResource>;
|
|
15
|
+
|
|
16
|
+
for (const resource of resources) {
|
|
17
|
+
result[resource.identity] = resource;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
export function extractNucleusMap<
|
|
27
|
+
TKey extends string = string,
|
|
28
|
+
TNucleus extends { identity: string | number | boolean } = { identity: string | number | boolean },
|
|
29
|
+
TResource extends ResourceJson = ResourceJson
|
|
30
|
+
>(
|
|
31
|
+
resourceMap: ResourceMap,
|
|
32
|
+
resourceTypeHandle: ResourceTypeIdentityJson,
|
|
33
|
+
): Map<TKey, TNucleus> {
|
|
34
|
+
const resources = extractResourcesByType<TResource>(resourceMap, resourceTypeHandle);
|
|
35
|
+
const out = new Map<TKey, TNucleus>();
|
|
36
|
+
|
|
37
|
+
for (const resource of Object.values(resources)) {
|
|
38
|
+
const data = (resource as any).nucleus as unknown;
|
|
39
|
+
|
|
40
|
+
const value = data as TNucleus;
|
|
41
|
+
const key = String(value.identity) as TKey;
|
|
42
|
+
|
|
43
|
+
out.set(key, value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return out;
|
|
47
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"types": ["node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"src"
|
|
10
|
-
],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"dist",
|
|
13
|
-
"node_modules"
|
|
14
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"types": ["node"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"exclude": [
|
|
12
|
+
"dist",
|
|
13
|
+
"node_modules"
|
|
14
|
+
]
|
|
15
15
|
}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/_lib/setup/
|
|
1
|
+
{"root":["./src/_lib/setup/firebaseAdminInit.ts","./src/artifacts/artifacts.ts","./src/firebase/firebaseAdminHelpers.ts","./src/types/types.ts","./src/utils/creation.ts","./src/utils/resourceMapExtraction.ts"],"version":"5.9.3"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ResourceIdentityJson, ResourceTypeIdentityJson, ResourceJson } from '@toolproof-core/schema';
|
|
2
|
-
import type { ResourceMap } from '../types/types.js';
|
|
3
|
-
export declare function extractResourcesByType<TResource extends ResourceJson = ResourceJson>(resourceMap: ResourceMap, resourceTypeHandle: ResourceTypeIdentityJson): Record<ResourceIdentityJson, TResource>;
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractNucleusMap<TKey extends string = string, TNucleus extends {
|
|
8
|
-
identity: string | number | boolean;
|
|
9
|
-
} = {
|
|
10
|
-
identity: string | number | boolean;
|
|
11
|
-
}, TResource extends ResourceJson = ResourceJson>(resourceMap: ResourceMap, resourceTypeHandle: ResourceTypeIdentityJson): Map<TKey, TNucleus>;
|
|
12
|
-
//# sourceMappingURL=extraction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../src/utils/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,EAChF,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,wBAAwB,GAC7C,MAAM,CAAC,oBAAoB,EAAE,SAAS,CAAC,CASzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,SAAS,MAAM,GAAG,MAAM,EAC5B,QAAQ,SAAS;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,EAClG,SAAS,SAAS,YAAY,GAAG,YAAY,EAE7C,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,wBAAwB,GAC7C,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAcrB"}
|
package/dist/utils/extraction.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function extractResourcesByType(resourceMap, resourceTypeHandle) {
|
|
2
|
-
const resources = (resourceMap[resourceTypeHandle] ?? []);
|
|
3
|
-
const result = {};
|
|
4
|
-
for (const resource of resources) {
|
|
5
|
-
result[resource.identity] = resource;
|
|
6
|
-
}
|
|
7
|
-
return result;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export function extractNucleusMap(resourceMap, resourceTypeHandle) {
|
|
13
|
-
const resources = extractResourcesByType(resourceMap, resourceTypeHandle);
|
|
14
|
-
const out = new Map();
|
|
15
|
-
for (const resource of Object.values(resources)) {
|
|
16
|
-
const data = resource.nucleus;
|
|
17
|
-
const value = data;
|
|
18
|
-
const key = String(value.identity);
|
|
19
|
-
out.set(key, value);
|
|
20
|
-
}
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
/* // ATTENTION: Should be retired in favor of extractNucleusMap
|
|
24
|
-
export function extractJobMap(resourceMap: ResourceMap) {
|
|
25
|
-
return extractNucleusMap<JobIdentityJson, JobJson, Resource_JobJson>(resourceMap, 'TYPE-Job');
|
|
26
|
-
} */
|
|
27
|
-
//# sourceMappingURL=extraction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.js","sourceRoot":"","sources":["../../src/utils/extraction.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,sBAAsB,CAClC,WAAwB,EACxB,kBAA4C;IAE5C,MAAM,SAAS,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAgB,CAAC;IACzE,MAAM,MAAM,GAA4C,EAA6C,CAAC;IAEtG,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAK7B,WAAwB,EACxB,kBAA4C;IAE5C,MAAM,SAAS,GAAG,sBAAsB,CAAY,WAAW,EAAE,kBAAkB,CAAC,CAAC;IACrF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAI,QAAgB,CAAC,OAAkB,CAAC;QAElD,MAAM,KAAK,GAAG,IAAgB,CAAC;QAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAS,CAAC;QAE3C,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;IAGI"}
|