@toolproof-npm/shared 0.1.31 → 0.1.32
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/constants.d.ts +15 -15
- package/dist/constants.js +15 -15
- package/dist/firebaseAdminHelpers.d.ts +7 -7
- package/dist/firebaseAdminHelpers.js +22 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +14 -14
- package/package.json +2 -2
package/dist/constants.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export declare const CONSTANTS: {
|
|
2
2
|
readonly SCHEMA: {
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
3
|
+
readonly ResourceFormatData: "ResourceFormatData";
|
|
4
|
+
readonly ResourceTypeData: "ResourceTypeData";
|
|
5
5
|
readonly Execution: "Execution";
|
|
6
6
|
readonly ResourceMap: "ResourceMap";
|
|
7
7
|
};
|
|
8
8
|
readonly STORAGE: {
|
|
9
9
|
readonly BUCKETS: {
|
|
10
|
-
readonly
|
|
10
|
+
readonly tp_resourceshapes: "tp-resourceshapes";
|
|
11
11
|
readonly tp_resources: "tp-resources";
|
|
12
12
|
};
|
|
13
13
|
readonly COLLECTIONS: {
|
|
14
|
-
readonly
|
|
14
|
+
readonly resourceshapes: "resourceshapes";
|
|
15
15
|
readonly resources: "resources";
|
|
16
16
|
};
|
|
17
17
|
readonly FILTER: {
|
|
@@ -19,11 +19,11 @@ export declare const CONSTANTS: {
|
|
|
19
19
|
readonly specials: "specials";
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
readonly
|
|
22
|
+
readonly RESOURCESHAPES: {
|
|
23
23
|
readonly formats: "formats";
|
|
24
24
|
readonly types: "types";
|
|
25
25
|
};
|
|
26
|
-
readonly
|
|
26
|
+
readonly RESOURCESHAPES_PSEUDO: {
|
|
27
27
|
readonly roles: "roles";
|
|
28
28
|
};
|
|
29
29
|
readonly RESOURCES: {
|
|
@@ -45,19 +45,19 @@ export declare const CONSTANTS: {
|
|
|
45
45
|
readonly GraphRunWorkflow: "GraphRunWorkflow";
|
|
46
46
|
};
|
|
47
47
|
readonly SPECIALS: {
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
readonly
|
|
55
|
-
readonly
|
|
48
|
+
readonly RF_ApplicationPrimitive: "RF-ApplicationPrimitive";
|
|
49
|
+
readonly RF_ApplicationJson: "RF-ApplicationJson";
|
|
50
|
+
readonly RF_ApplicationJob: "RF-ApplicationJob";
|
|
51
|
+
readonly RT_Boolean: "RT-Boolean";
|
|
52
|
+
readonly RT_Integer: "RT-Integer";
|
|
53
|
+
readonly RT_Job: "RT-Job";
|
|
54
|
+
readonly RT_WorkflowSpec: "RT-WorkflowSpec";
|
|
55
|
+
readonly RR_BUILDER: "RR-Builder";
|
|
56
56
|
readonly JOB_Engine: "JOB-Engine";
|
|
57
57
|
readonly BOOLEAN_false: "RESOURCE-c2kAldyzgNhLdF79p0Vt";
|
|
58
58
|
readonly BOOLEAN_true: "RESOURCE-FHycY5TxwEBngKVhkv2j";
|
|
59
59
|
};
|
|
60
60
|
readonly TESTING: {
|
|
61
|
-
readonly Integer_Zero: "
|
|
61
|
+
readonly Integer_Zero: "RT-Integer/3335e31095a13a9a2b0ea41ca7d92a458780cd5671dc0a440a72cc1b1c4f2c81";
|
|
62
62
|
};
|
|
63
63
|
};
|
package/dist/constants.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const CONSTANTS = {
|
|
2
2
|
SCHEMA: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
ResourceFormatData: 'ResourceFormatData',
|
|
4
|
+
ResourceTypeData: 'ResourceTypeData',
|
|
5
5
|
Execution: 'Execution',
|
|
6
6
|
ResourceMap: 'ResourceMap',
|
|
7
7
|
},
|
|
8
8
|
STORAGE: {
|
|
9
9
|
BUCKETS: {
|
|
10
|
-
|
|
10
|
+
tp_resourceshapes: 'tp-resourceshapes',
|
|
11
11
|
tp_resources: 'tp-resources',
|
|
12
12
|
},
|
|
13
13
|
COLLECTIONS: {
|
|
14
|
-
|
|
14
|
+
resourceshapes: 'resourceshapes',
|
|
15
15
|
resources: 'resources',
|
|
16
16
|
},
|
|
17
17
|
FILTER: {
|
|
@@ -19,11 +19,11 @@ export const CONSTANTS = {
|
|
|
19
19
|
specials: 'specials',
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
RESOURCESHAPES: {
|
|
23
23
|
formats: 'formats',
|
|
24
24
|
types: 'types',
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
RESOURCESHAPES_PSEUDO: {
|
|
27
27
|
roles: 'roles',
|
|
28
28
|
},
|
|
29
29
|
RESOURCES: {
|
|
@@ -45,19 +45,19 @@ export const CONSTANTS = {
|
|
|
45
45
|
GraphRunWorkflow: 'GraphRunWorkflow',
|
|
46
46
|
},
|
|
47
47
|
SPECIALS: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
RF_ApplicationPrimitive: 'RF-ApplicationPrimitive',
|
|
49
|
+
RF_ApplicationJson: 'RF-ApplicationJson',
|
|
50
|
+
RF_ApplicationJob: 'RF-ApplicationJob',
|
|
51
|
+
RT_Boolean: 'RT-Boolean',
|
|
52
|
+
RT_Integer: 'RT-Integer',
|
|
53
|
+
RT_Job: 'RT-Job',
|
|
54
|
+
RT_WorkflowSpec: 'RT-WorkflowSpec',
|
|
55
|
+
RR_BUILDER: 'RR-Builder',
|
|
56
56
|
JOB_Engine: 'JOB-Engine',
|
|
57
57
|
BOOLEAN_false: 'RESOURCE-c2kAldyzgNhLdF79p0Vt',
|
|
58
58
|
BOOLEAN_true: 'RESOURCE-FHycY5TxwEBngKVhkv2j',
|
|
59
59
|
},
|
|
60
60
|
TESTING: {
|
|
61
|
-
Integer_Zero: '
|
|
61
|
+
Integer_Zero: 'RT-Integer/3335e31095a13a9a2b0ea41ca7d92a458780cd5671dc0a440a72cc1b1c4f2c81',
|
|
62
62
|
}
|
|
63
63
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { FilterConst,
|
|
3
|
-
export declare function getNewId(identifiable:
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function listResourcesMeta(
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function listResourcesData(
|
|
1
|
+
import type { ResourceTypeIdJson } from '@toolproof-npm/schema';
|
|
2
|
+
import type { FilterConst, ResourceShapeConst, RoleConst, StepConst, WorkflowConst, ArcheresourceTypeMeta, ArcheresourceTypeData, ArcheresourceTypeMetaMap, ArcheresourceTypeDataMap, ResourceMetaMap, ResourceDataMap, ResourceConst } from './types.d.ts';
|
|
3
|
+
export declare function getNewId(identifiable: ResourceShapeConst | RoleConst | ResourceConst | StepConst | WorkflowConst): string;
|
|
4
|
+
export declare function listResourceShapesMeta<T extends ArcheresourceTypeMeta>(groupKey: ResourceShapeConst, filterConfig: Record<FilterConst, boolean>): Promise<ArcheresourceTypeMetaMap<T>>;
|
|
5
|
+
export declare function listResourcesMeta(resourceTypeIds: ResourceTypeIdJson[]): Promise<ResourceMetaMap>;
|
|
6
|
+
export declare function listResourceShapesData<T extends ArcheresourceTypeData>(groupKey: ResourceShapeConst, filterConfig: Record<FilterConst, boolean>): Promise<ArcheresourceTypeDataMap<T>>;
|
|
7
|
+
export declare function listResourcesData(resourceTypeIds: ResourceTypeIdJson[]): Promise<ResourceDataMap>;
|
|
@@ -4,12 +4,12 @@ export function getNewId(identifiable) {
|
|
|
4
4
|
const base = identifiable.toUpperCase();
|
|
5
5
|
const normalized = base.endsWith('S') ? base.slice(0, -1) : base;
|
|
6
6
|
const prefix = normalized + '-';
|
|
7
|
-
const docRef = dbAdmin.collection(CONSTANTS.STORAGE.COLLECTIONS.
|
|
7
|
+
const docRef = dbAdmin.collection(CONSTANTS.STORAGE.COLLECTIONS.resourceshapes).doc(identifiable).collection(CONSTANTS.STORAGE.FILTER.members).doc();
|
|
8
8
|
return prefix + docRef.id;
|
|
9
9
|
}
|
|
10
|
-
export async function
|
|
10
|
+
export async function listResourceShapesMeta(groupKey, filterConfig) {
|
|
11
11
|
const baseRef = dbAdmin
|
|
12
|
-
.collection(CONSTANTS.STORAGE.COLLECTIONS.
|
|
12
|
+
.collection(CONSTANTS.STORAGE.COLLECTIONS.resourceshapes)
|
|
13
13
|
.doc(groupKey);
|
|
14
14
|
const entries = await Promise.all([
|
|
15
15
|
filterConfig.members
|
|
@@ -28,12 +28,12 @@ export async function listArchetypesMeta(groupKey, filterConfig) {
|
|
|
28
28
|
const [members, specials] = entries;
|
|
29
29
|
return { members, specials };
|
|
30
30
|
}
|
|
31
|
-
export async function listResourcesMeta(
|
|
31
|
+
export async function listResourcesMeta(resourceTypeIds) {
|
|
32
32
|
const collectionName = CONSTANTS.STORAGE.COLLECTIONS.resources;
|
|
33
|
-
const entries = await Promise.all(
|
|
33
|
+
const entries = await Promise.all(resourceTypeIds.map(async (resourceTypeId) => {
|
|
34
34
|
const snap = await dbAdmin
|
|
35
35
|
.collection(collectionName)
|
|
36
|
-
.doc(
|
|
36
|
+
.doc(resourceTypeId)
|
|
37
37
|
.collection(CONSTANTS.STORAGE.FILTER.members)
|
|
38
38
|
.get();
|
|
39
39
|
const items = snap.docs.map(d => {
|
|
@@ -41,12 +41,12 @@ export async function listResourcesMeta(typeIds) {
|
|
|
41
41
|
// Ensure id field is present (doc id is the resourceId)
|
|
42
42
|
return { ...data, id: d.id };
|
|
43
43
|
});
|
|
44
|
-
return [
|
|
44
|
+
return [resourceTypeId, items];
|
|
45
45
|
}));
|
|
46
46
|
return Object.fromEntries(entries);
|
|
47
47
|
}
|
|
48
|
-
export async function
|
|
49
|
-
const bucket = storageAdmin.bucket(CONSTANTS.STORAGE.BUCKETS.
|
|
48
|
+
export async function listResourceShapesData(groupKey, filterConfig) {
|
|
49
|
+
const bucket = storageAdmin.bucket(CONSTANTS.STORAGE.BUCKETS.tp_resourceshapes);
|
|
50
50
|
const prefix = `${groupKey}/`;
|
|
51
51
|
const [files] = await bucket.getFiles({ prefix });
|
|
52
52
|
const result = {
|
|
@@ -70,10 +70,10 @@ export async function listArchetypesData(groupKey, filterConfig) {
|
|
|
70
70
|
await Promise.all(tasks);
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
|
-
export async function listResourcesData(
|
|
73
|
+
export async function listResourcesData(resourceTypeIds) {
|
|
74
74
|
const bucket = storageAdmin.bucket(CONSTANTS.STORAGE.BUCKETS.tp_resources);
|
|
75
|
-
async function fetchFilesUnder(
|
|
76
|
-
const prefix = `${
|
|
75
|
+
async function fetchFilesUnder(resourceTypeId) {
|
|
76
|
+
const prefix = `${resourceTypeId}/`;
|
|
77
77
|
const [found] = await bucket.getFiles({ prefix });
|
|
78
78
|
const files = found.filter(f => {
|
|
79
79
|
const name = f.name || '';
|
|
@@ -96,8 +96,8 @@ export async function listResourcesData(typeIds) {
|
|
|
96
96
|
}));
|
|
97
97
|
return items.filter(Boolean);
|
|
98
98
|
}
|
|
99
|
-
const entries = await Promise.all(
|
|
100
|
-
const rows = await fetchFilesUnder(
|
|
99
|
+
const entries = await Promise.all(resourceTypeIds.map(async (resourceTypeId) => {
|
|
100
|
+
const rows = await fetchFilesUnder(resourceTypeId);
|
|
101
101
|
const items = rows.map(({ data, meta, name }) => {
|
|
102
102
|
const flat = meta?.metadata ?? {};
|
|
103
103
|
// Reconstruct nested object from flattened keys (dot and array index notation)
|
|
@@ -153,17 +153,17 @@ export async function listResourcesData(typeIds) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
const idMeta = root.id;
|
|
156
|
-
const
|
|
157
|
-
// creationContext may be flattened as creationContext.
|
|
158
|
-
const
|
|
156
|
+
const resourceTypeIdMeta = root.resourceTypeId;
|
|
157
|
+
// creationContext may be flattened as creationContext.resourceRoleId or direct resourceRoleId
|
|
158
|
+
const resourceRoleId = (root.creationContext?.resourceRoleId ?? root.resourceRoleId);
|
|
159
159
|
const executionId = (root.creationContext?.executionId ?? root.executionId);
|
|
160
160
|
const kind = root.kind;
|
|
161
161
|
const path = root.path;
|
|
162
162
|
const timestamp = root.timestamp;
|
|
163
163
|
const missing = [
|
|
164
164
|
['id', idMeta],
|
|
165
|
-
['
|
|
166
|
-
['
|
|
165
|
+
['resourceTypeId', resourceTypeIdMeta],
|
|
166
|
+
['resourceRoleId', resourceRoleId],
|
|
167
167
|
['executionId', executionId],
|
|
168
168
|
['kind', kind],
|
|
169
169
|
['path', path],
|
|
@@ -175,9 +175,9 @@ export async function listResourcesData(typeIds) {
|
|
|
175
175
|
}
|
|
176
176
|
return {
|
|
177
177
|
id: idMeta,
|
|
178
|
-
|
|
178
|
+
resourceTypeId: resourceTypeIdMeta,
|
|
179
179
|
creationContext: {
|
|
180
|
-
|
|
180
|
+
resourceRoleId: resourceRoleId,
|
|
181
181
|
executionId: executionId,
|
|
182
182
|
},
|
|
183
183
|
kind: kind,
|
|
@@ -186,7 +186,7 @@ export async function listResourcesData(typeIds) {
|
|
|
186
186
|
extractedData: data,
|
|
187
187
|
};
|
|
188
188
|
});
|
|
189
|
-
return [
|
|
189
|
+
return [resourceTypeId, items];
|
|
190
190
|
}));
|
|
191
191
|
return Object.fromEntries(entries);
|
|
192
192
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { ResourceIdJson, ExecutionIdJson,
|
|
1
|
+
import type { ResourceIdJson, ExecutionIdJson, ResourceRoleIdJson, RoleLiteralJson, ResourceTypeIdJson, ResourceFormatMetaJson, ResourceFormatDataJson, ResourceTypeMetaJson, ResourceTypeDataJson, ResourceMetaJson, ResourceDataJson } from '@toolproof-npm/schema';
|
|
2
2
|
import { CONSTANTS } from './constants.js';
|
|
3
|
-
export type BucketConst = typeof CONSTANTS.STORAGE.BUCKETS.
|
|
4
|
-
export type CollectionConst = typeof CONSTANTS.STORAGE.COLLECTIONS.
|
|
3
|
+
export type BucketConst = typeof CONSTANTS.STORAGE.BUCKETS.tp_resourceshapes | typeof CONSTANTS.STORAGE.BUCKETS.tp_resources;
|
|
4
|
+
export type CollectionConst = typeof CONSTANTS.STORAGE.COLLECTIONS.resourceshapes | typeof CONSTANTS.STORAGE.COLLECTIONS.resources;
|
|
5
5
|
export type FilterConst = typeof CONSTANTS.STORAGE.FILTER.members | typeof CONSTANTS.STORAGE.FILTER.specials;
|
|
6
|
-
export type
|
|
7
|
-
export type RoleConst = typeof CONSTANTS.
|
|
6
|
+
export type ResourceShapeConst = typeof CONSTANTS.RESOURCESHAPES.formats | typeof CONSTANTS.RESOURCESHAPES.types;
|
|
7
|
+
export type RoleConst = typeof CONSTANTS.RESOURCESHAPES_PSEUDO.roles;
|
|
8
8
|
export type ResourceConst = typeof CONSTANTS.RESOURCES.resources;
|
|
9
9
|
export type StepConst = typeof CONSTANTS.STEP.work | typeof CONSTANTS.STEP.branch | typeof CONSTANTS.STEP.while | typeof CONSTANTS.STEP.for;
|
|
10
10
|
export type WorkflowConst = typeof CONSTANTS.WORKFLOW.workflow | typeof CONSTANTS.WORKFLOW.workflowSpec | typeof CONSTANTS.WORKFLOW.execution;
|
|
11
11
|
export type Role = {
|
|
12
|
-
id:
|
|
12
|
+
id: ResourceRoleIdJson;
|
|
13
13
|
} & RoleLiteralJson;
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type ResourceMetaMap = Record<
|
|
19
|
-
export type ResourceDataMap = Record<
|
|
14
|
+
export type ArcheresourceTypeData = ResourceFormatDataJson | ResourceTypeDataJson;
|
|
15
|
+
export type ArcheresourceTypeMeta = ResourceFormatMetaJson | ResourceTypeMetaJson;
|
|
16
|
+
export type ArcheresourceTypeDataMap<T extends ArcheresourceTypeData> = Record<FilterConst, T[]>;
|
|
17
|
+
export type ArcheresourceTypeMetaMap<T extends ArcheresourceTypeMeta> = Record<FilterConst, T[]>;
|
|
18
|
+
export type ResourceMetaMap = Record<ResourceTypeIdJson, ResourceMetaJson[]>;
|
|
19
|
+
export type ResourceDataMap = Record<ResourceTypeIdJson, ResourceDataJson[]>;
|
|
20
20
|
export type ExternallyProvidedResourceMeta = {
|
|
21
21
|
id: ResourceIdJson;
|
|
22
|
-
|
|
22
|
+
resourceTypeId: ResourceTypeIdJson;
|
|
23
23
|
creationContext: {
|
|
24
|
-
|
|
24
|
+
resourceRoleId: ResourceRoleIdJson;
|
|
25
25
|
executionId: ExecutionIdJson;
|
|
26
26
|
};
|
|
27
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolproof-npm/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Core library utilities for ToolProof",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"toolproof",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@toolproof-npm/schema": "^0.1.
|
|
55
|
+
"@toolproof-npm/schema": "^0.1.31",
|
|
56
56
|
"firebase-admin": "^13.6.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|