@fabricorg/gen-conformance 0.1.1 → 0.2.0
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/CHANGELOG.md +30 -0
- package/dist/index.cjs +289 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -2
- package/dist/index.d.ts +127 -2
- package/dist/index.js +281 -6
- package/dist/index.js.map +1 -1
- package/dist/memory.cjs +114 -0
- package/dist/memory.cjs.map +1 -0
- package/dist/memory.d.cts +19 -0
- package/dist/memory.d.ts +19 -0
- package/dist/memory.js +89 -0
- package/dist/memory.js.map +1 -0
- package/package.json +19 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../memory.ts"],"sourcesContent":["import { createModuleRegistry, type FabricModule } from \"@fabricorg/platform\";\nimport { createGovernedActionHost, digestParameters, MemoryPlatformHostStore } from \"@fabricorg/platform-host\";\nimport type { ConformanceEventEnvelope, ConformanceHarness, ConformanceScope, ConformanceSubmitInput } from \"./index\";\n\nexport interface MemoryConformanceHarnessOptions<TDb = undefined> {\n\tmodules: FabricModule<TDb>[];\n\t/** Representative parameters per actionId. Actions without an entry receive `{}`. */\n\tparameters?: Record<string, Record<string, unknown>>;\n\tdb?: TDb;\n\tscope?: Partial<ConformanceScope>;\n}\n\nconst DEFAULT_SCOPE: ConformanceScope = {\n\ttenantId: \"conformance-tenant\",\n\tspaceId: \"conformance-space\",\n\tactorId: \"conformance-actor\",\n\tactorType: \"natural_person\",\n};\n\n/**\n * Reference harness: a governed host over an in-memory store, so a generated suite\n * runs with no database, queue or network. Execution authority is withdrawable so\n * the offline-replay check has something real to be refused by.\n */\nexport function createMemoryConformanceHarness<TDb = undefined>(\n\toptions: MemoryConformanceHarnessOptions<TDb>,\n): ConformanceHarness {\n\tconst scope: ConformanceScope = { ...DEFAULT_SCOPE, ...options.scope };\n\tconst registry = createModuleRegistry(options.modules);\n\tconst store = new MemoryPlatformHostStore<TDb>(options.db as TDb);\n\tconst revoked = new Set<string>();\n\tconst host = createGovernedActionHost<TDb>({\n\t\tstore,\n\t\tregistry,\n\t\tauthorization: {\n\t\t\tcheckEntitlement: async () => true,\n\t\t\t// Capture-time authority always holds; only execution-time authority is withdrawable.\n\t\t\tauthorize: async () => true,\n\t\t\tauthorizeExecution: async (input) => !revoked.has(input.actionId),\n\t\t},\n\t});\n\n\tconst parameters = (actionId: string): Record<string, unknown> => options.parameters?.[actionId] ?? {};\n\n\treturn {\n\t\tscope,\n\t\tparameters,\n\t\tasync submit(input: ConformanceSubmitInput) {\n\t\t\tconst binding = input.authorizationBinding;\n\t\t\tconst result = await host.submitAction({\n\t\t\t\tactionId: input.actionId as `${string}.${string}`,\n\t\t\t\tparameters: input.parameters,\n\t\t\t\ttenantId: scope.tenantId,\n\t\t\t\tspaceId: scope.spaceId,\n\t\t\t\tactorId: scope.actorId,\n\t\t\t\tactorType: scope.actorType as \"natural_person\",\n\t\t\t\t...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}),\n\t\t\t\t...(input.correlationId ? { correlationId: input.correlationId } : {}),\n\t\t\t\t...(input.provenance ? { provenance: input.provenance as never } : {}),\n\t\t\t\t...(input.executionReason ? { executionReason: input.executionReason } : {}),\n\t\t\t\t...(binding\n\t\t\t\t\t? {\n\t\t\t\t\t\tauthorizationBinding: {\n\t\t\t\t\t\t\tid: `conformance-binding-${input.actionId}`,\n\t\t\t\t\t\t\ttenantId: scope.tenantId,\n\t\t\t\t\t\t\tactorId: scope.actorId,\n\t\t\t\t\t\t\tactionId: input.actionId,\n\t\t\t\t\t\t\tparameterDigest: digestParameters(input.parameters),\n\t\t\t\t\t\t\tcapturedAt: binding.capturedAt ?? new Date().toISOString(),\n\t\t\t\t\t\t\t...(binding.expiresAt ? { expiresAt: binding.expiresAt } : {}),\n\t\t\t\t\t\t\tgoverningMoment: binding.governingMoment,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tactionInvocationId: result.actionInvocationId,\n\t\t\t\tstatus: result.status,\n\t\t\t\t...(result.reconciliation ? { reconciliation: { kind: result.reconciliation.kind } } : {}),\n\t\t\t};\n\t\t},\n\t\tasync events() {\n\t\t\t// Widen the known envelope into the tolerant shape the contract describes:\n\t\t\t// a conformance consumer must cope with fields it does not recognise.\n\t\t\treturn (await store.listEvents(scope.tenantId, scope.spaceId)).map((event) => ({ ...event }) as ConformanceEventEnvelope);\n\t\t},\n\t\tasync revokeAuthority(actionId: string) {\n\t\t\trevoked.add(actionId);\n\t\t},\n\t\tasync acceptsEnvelope(envelope: ConformanceEventEnvelope) {\n\t\t\t// A view reducer is a real consumer: fold the envelope and see whether it survives.\n\t\t\tconst consumers = options.modules.flatMap((module) => module.views ?? [])\n\t\t\t\t.filter((view) => view.consumes.some((consumption) => consumption.eventType === envelope.eventType));\n\t\t\tfor (const view of consumers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait view.applyEvent(view.initialState as never, envelope as never);\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\tasync sideEffects(actionId: string) {\n\t\t\t// Events are the observable effect of a governed handler running.\n\t\t\tconst invocations = await store.listActionInvocations({ tenantId: scope.tenantId, spaceId: scope.spaceId });\n\t\t\tconst ours = new Set(invocations.filter((invocation) => invocation.actionId === actionId).map((invocation) => invocation.id));\n\t\t\tconst events = await store.listEvents(scope.tenantId, scope.spaceId);\n\t\t\treturn events.filter((event) => event.actionInvocationId !== undefined && ours.has(event.actionInvocationId)).length;\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAwD;AACxD,2BAAoF;AAWpF,IAAM,gBAAkC;AAAA,EACvC,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AACZ;AAOO,SAAS,+BAC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O,OAAO,OAAO,CAAC,UAAU,MAAM,uBAAuB,UAAa,KAAK,IAAI,MAAM,kBAAkB,CAAC,EAAE;AAAA,IAC/G;AAAA,EACD;AACD;","names":["module"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FabricModule } from '@fabricorg/platform';
|
|
2
|
+
import { ConformanceScope, ConformanceHarness } from './index.cjs';
|
|
3
|
+
import '@fabricorg/compiler';
|
|
4
|
+
|
|
5
|
+
interface MemoryConformanceHarnessOptions<TDb = undefined> {
|
|
6
|
+
modules: FabricModule<TDb>[];
|
|
7
|
+
/** Representative parameters per actionId. Actions without an entry receive `{}`. */
|
|
8
|
+
parameters?: Record<string, Record<string, unknown>>;
|
|
9
|
+
db?: TDb;
|
|
10
|
+
scope?: Partial<ConformanceScope>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reference harness: a governed host over an in-memory store, so a generated suite
|
|
14
|
+
* runs with no database, queue or network. Execution authority is withdrawable so
|
|
15
|
+
* the offline-replay check has something real to be refused by.
|
|
16
|
+
*/
|
|
17
|
+
declare function createMemoryConformanceHarness<TDb = undefined>(options: MemoryConformanceHarnessOptions<TDb>): ConformanceHarness;
|
|
18
|
+
|
|
19
|
+
export { type MemoryConformanceHarnessOptions, createMemoryConformanceHarness };
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FabricModule } from '@fabricorg/platform';
|
|
2
|
+
import { ConformanceScope, ConformanceHarness } from './index.js';
|
|
3
|
+
import '@fabricorg/compiler';
|
|
4
|
+
|
|
5
|
+
interface MemoryConformanceHarnessOptions<TDb = undefined> {
|
|
6
|
+
modules: FabricModule<TDb>[];
|
|
7
|
+
/** Representative parameters per actionId. Actions without an entry receive `{}`. */
|
|
8
|
+
parameters?: Record<string, Record<string, unknown>>;
|
|
9
|
+
db?: TDb;
|
|
10
|
+
scope?: Partial<ConformanceScope>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reference harness: a governed host over an in-memory store, so a generated suite
|
|
14
|
+
* runs with no database, queue or network. Execution authority is withdrawable so
|
|
15
|
+
* the offline-replay check has something real to be refused by.
|
|
16
|
+
*/
|
|
17
|
+
declare function createMemoryConformanceHarness<TDb = undefined>(options: MemoryConformanceHarnessOptions<TDb>): ConformanceHarness;
|
|
18
|
+
|
|
19
|
+
export { type MemoryConformanceHarnessOptions, createMemoryConformanceHarness };
|
package/dist/memory.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// memory.ts
|
|
2
|
+
import { createModuleRegistry } from "@fabricorg/platform";
|
|
3
|
+
import { createGovernedActionHost, digestParameters, MemoryPlatformHostStore } from "@fabricorg/platform-host";
|
|
4
|
+
var DEFAULT_SCOPE = {
|
|
5
|
+
tenantId: "conformance-tenant",
|
|
6
|
+
spaceId: "conformance-space",
|
|
7
|
+
actorId: "conformance-actor",
|
|
8
|
+
actorType: "natural_person"
|
|
9
|
+
};
|
|
10
|
+
function createMemoryConformanceHarness(options) {
|
|
11
|
+
const scope = { ...DEFAULT_SCOPE, ...options.scope };
|
|
12
|
+
const registry = createModuleRegistry(options.modules);
|
|
13
|
+
const store = new MemoryPlatformHostStore(options.db);
|
|
14
|
+
const revoked = /* @__PURE__ */ new Set();
|
|
15
|
+
const host = createGovernedActionHost({
|
|
16
|
+
store,
|
|
17
|
+
registry,
|
|
18
|
+
authorization: {
|
|
19
|
+
checkEntitlement: async () => true,
|
|
20
|
+
// Capture-time authority always holds; only execution-time authority is withdrawable.
|
|
21
|
+
authorize: async () => true,
|
|
22
|
+
authorizeExecution: async (input) => !revoked.has(input.actionId)
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const parameters = (actionId) => options.parameters?.[actionId] ?? {};
|
|
26
|
+
return {
|
|
27
|
+
scope,
|
|
28
|
+
parameters,
|
|
29
|
+
async submit(input) {
|
|
30
|
+
const binding = input.authorizationBinding;
|
|
31
|
+
const result = await host.submitAction({
|
|
32
|
+
actionId: input.actionId,
|
|
33
|
+
parameters: input.parameters,
|
|
34
|
+
tenantId: scope.tenantId,
|
|
35
|
+
spaceId: scope.spaceId,
|
|
36
|
+
actorId: scope.actorId,
|
|
37
|
+
actorType: scope.actorType,
|
|
38
|
+
...input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {},
|
|
39
|
+
...input.correlationId ? { correlationId: input.correlationId } : {},
|
|
40
|
+
...input.provenance ? { provenance: input.provenance } : {},
|
|
41
|
+
...input.executionReason ? { executionReason: input.executionReason } : {},
|
|
42
|
+
...binding ? {
|
|
43
|
+
authorizationBinding: {
|
|
44
|
+
id: `conformance-binding-${input.actionId}`,
|
|
45
|
+
tenantId: scope.tenantId,
|
|
46
|
+
actorId: scope.actorId,
|
|
47
|
+
actionId: input.actionId,
|
|
48
|
+
parameterDigest: digestParameters(input.parameters),
|
|
49
|
+
capturedAt: binding.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
50
|
+
...binding.expiresAt ? { expiresAt: binding.expiresAt } : {},
|
|
51
|
+
governingMoment: binding.governingMoment
|
|
52
|
+
}
|
|
53
|
+
} : {}
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
actionInvocationId: result.actionInvocationId,
|
|
57
|
+
status: result.status,
|
|
58
|
+
...result.reconciliation ? { reconciliation: { kind: result.reconciliation.kind } } : {}
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
async events() {
|
|
62
|
+
return (await store.listEvents(scope.tenantId, scope.spaceId)).map((event) => ({ ...event }));
|
|
63
|
+
},
|
|
64
|
+
async revokeAuthority(actionId) {
|
|
65
|
+
revoked.add(actionId);
|
|
66
|
+
},
|
|
67
|
+
async acceptsEnvelope(envelope) {
|
|
68
|
+
const consumers = options.modules.flatMap((module) => module.views ?? []).filter((view) => view.consumes.some((consumption) => consumption.eventType === envelope.eventType));
|
|
69
|
+
for (const view of consumers) {
|
|
70
|
+
try {
|
|
71
|
+
await view.applyEvent(view.initialState, envelope);
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
async sideEffects(actionId) {
|
|
79
|
+
const invocations = await store.listActionInvocations({ tenantId: scope.tenantId, spaceId: scope.spaceId });
|
|
80
|
+
const ours = new Set(invocations.filter((invocation) => invocation.actionId === actionId).map((invocation) => invocation.id));
|
|
81
|
+
const events = await store.listEvents(scope.tenantId, scope.spaceId);
|
|
82
|
+
return events.filter((event) => event.actionInvocationId !== void 0 && ours.has(event.actionInvocationId)).length;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
createMemoryConformanceHarness
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../memory.ts"],"sourcesContent":["import { createModuleRegistry, type FabricModule } from \"@fabricorg/platform\";\nimport { createGovernedActionHost, digestParameters, MemoryPlatformHostStore } from \"@fabricorg/platform-host\";\nimport type { ConformanceEventEnvelope, ConformanceHarness, ConformanceScope, ConformanceSubmitInput } from \"./index\";\n\nexport interface MemoryConformanceHarnessOptions<TDb = undefined> {\n\tmodules: FabricModule<TDb>[];\n\t/** Representative parameters per actionId. Actions without an entry receive `{}`. */\n\tparameters?: Record<string, Record<string, unknown>>;\n\tdb?: TDb;\n\tscope?: Partial<ConformanceScope>;\n}\n\nconst DEFAULT_SCOPE: ConformanceScope = {\n\ttenantId: \"conformance-tenant\",\n\tspaceId: \"conformance-space\",\n\tactorId: \"conformance-actor\",\n\tactorType: \"natural_person\",\n};\n\n/**\n * Reference harness: a governed host over an in-memory store, so a generated suite\n * runs with no database, queue or network. Execution authority is withdrawable so\n * the offline-replay check has something real to be refused by.\n */\nexport function createMemoryConformanceHarness<TDb = undefined>(\n\toptions: MemoryConformanceHarnessOptions<TDb>,\n): ConformanceHarness {\n\tconst scope: ConformanceScope = { ...DEFAULT_SCOPE, ...options.scope };\n\tconst registry = createModuleRegistry(options.modules);\n\tconst store = new MemoryPlatformHostStore<TDb>(options.db as TDb);\n\tconst revoked = new Set<string>();\n\tconst host = createGovernedActionHost<TDb>({\n\t\tstore,\n\t\tregistry,\n\t\tauthorization: {\n\t\t\tcheckEntitlement: async () => true,\n\t\t\t// Capture-time authority always holds; only execution-time authority is withdrawable.\n\t\t\tauthorize: async () => true,\n\t\t\tauthorizeExecution: async (input) => !revoked.has(input.actionId),\n\t\t},\n\t});\n\n\tconst parameters = (actionId: string): Record<string, unknown> => options.parameters?.[actionId] ?? {};\n\n\treturn {\n\t\tscope,\n\t\tparameters,\n\t\tasync submit(input: ConformanceSubmitInput) {\n\t\t\tconst binding = input.authorizationBinding;\n\t\t\tconst result = await host.submitAction({\n\t\t\t\tactionId: input.actionId as `${string}.${string}`,\n\t\t\t\tparameters: input.parameters,\n\t\t\t\ttenantId: scope.tenantId,\n\t\t\t\tspaceId: scope.spaceId,\n\t\t\t\tactorId: scope.actorId,\n\t\t\t\tactorType: scope.actorType as \"natural_person\",\n\t\t\t\t...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}),\n\t\t\t\t...(input.correlationId ? { correlationId: input.correlationId } : {}),\n\t\t\t\t...(input.provenance ? { provenance: input.provenance as never } : {}),\n\t\t\t\t...(input.executionReason ? { executionReason: input.executionReason } : {}),\n\t\t\t\t...(binding\n\t\t\t\t\t? {\n\t\t\t\t\t\tauthorizationBinding: {\n\t\t\t\t\t\t\tid: `conformance-binding-${input.actionId}`,\n\t\t\t\t\t\t\ttenantId: scope.tenantId,\n\t\t\t\t\t\t\tactorId: scope.actorId,\n\t\t\t\t\t\t\tactionId: input.actionId,\n\t\t\t\t\t\t\tparameterDigest: digestParameters(input.parameters),\n\t\t\t\t\t\t\tcapturedAt: binding.capturedAt ?? new Date().toISOString(),\n\t\t\t\t\t\t\t...(binding.expiresAt ? { expiresAt: binding.expiresAt } : {}),\n\t\t\t\t\t\t\tgoverningMoment: binding.governingMoment,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tactionInvocationId: result.actionInvocationId,\n\t\t\t\tstatus: result.status,\n\t\t\t\t...(result.reconciliation ? { reconciliation: { kind: result.reconciliation.kind } } : {}),\n\t\t\t};\n\t\t},\n\t\tasync events() {\n\t\t\t// Widen the known envelope into the tolerant shape the contract describes:\n\t\t\t// a conformance consumer must cope with fields it does not recognise.\n\t\t\treturn (await store.listEvents(scope.tenantId, scope.spaceId)).map((event) => ({ ...event }) as ConformanceEventEnvelope);\n\t\t},\n\t\tasync revokeAuthority(actionId: string) {\n\t\t\trevoked.add(actionId);\n\t\t},\n\t\tasync acceptsEnvelope(envelope: ConformanceEventEnvelope) {\n\t\t\t// A view reducer is a real consumer: fold the envelope and see whether it survives.\n\t\t\tconst consumers = options.modules.flatMap((module) => module.views ?? [])\n\t\t\t\t.filter((view) => view.consumes.some((consumption) => consumption.eventType === envelope.eventType));\n\t\t\tfor (const view of consumers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait view.applyEvent(view.initialState as never, envelope as never);\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\tasync sideEffects(actionId: string) {\n\t\t\t// Events are the observable effect of a governed handler running.\n\t\t\tconst invocations = await store.listActionInvocations({ tenantId: scope.tenantId, spaceId: scope.spaceId });\n\t\t\tconst ours = new Set(invocations.filter((invocation) => invocation.actionId === actionId).map((invocation) => invocation.id));\n\t\t\tconst events = await store.listEvents(scope.tenantId, scope.spaceId);\n\t\t\treturn events.filter((event) => event.actionInvocationId !== undefined && ours.has(event.actionInvocationId)).length;\n\t\t},\n\t};\n}\n"],"mappings":";AAAA,SAAS,4BAA+C;AACxD,SAAS,0BAA0B,kBAAkB,+BAA+B;AAWpF,IAAM,gBAAkC;AAAA,EACvC,UAAU;AAAA,EAC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AAM,SAAS,MAAM,MAAM,WAAW,MAAM,UAAU,MAAM,OAAO;AACnE,aAAO,OAAO,OAAO,CAAC,UAAU,MAAM,uBAAuB,UAAa,KAAK,IAAI,MAAM,kBAAkB,CAAC,EAAE;AAAA,IAC/G;AAAA,EACD;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/gen-conformance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Deterministic Phase 1 capability conformance plans and certification evidence.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,16 @@
|
|
|
17
17
|
"types": "./dist/index.d.cts",
|
|
18
18
|
"default": "./dist/index.cjs"
|
|
19
19
|
}
|
|
20
|
+
},
|
|
21
|
+
"./memory": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/memory.d.ts",
|
|
24
|
+
"default": "./dist/memory.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/memory.d.cts",
|
|
28
|
+
"default": "./dist/memory.cjs"
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
},
|
|
22
32
|
"files": [
|
|
@@ -26,13 +36,15 @@
|
|
|
26
36
|
"LICENSE"
|
|
27
37
|
],
|
|
28
38
|
"dependencies": {
|
|
29
|
-
"@fabricorg/compiler": "^2.
|
|
39
|
+
"@fabricorg/compiler": "^2.1.0"
|
|
30
40
|
},
|
|
31
41
|
"devDependencies": {
|
|
32
42
|
"@types/node": "^22.10.0",
|
|
33
43
|
"tsup": "^8.5.0",
|
|
34
44
|
"typescript": "^5.7.3",
|
|
35
|
-
"vitest": "^4.1.5"
|
|
45
|
+
"vitest": "^4.1.5",
|
|
46
|
+
"@fabricorg/platform": "^1.1.0",
|
|
47
|
+
"@fabricorg/platform-host": "^5.0.0"
|
|
36
48
|
},
|
|
37
49
|
"engines": {
|
|
38
50
|
"node": ">=20"
|
|
@@ -40,6 +52,10 @@
|
|
|
40
52
|
"publishConfig": {
|
|
41
53
|
"access": "public"
|
|
42
54
|
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@fabricorg/platform": "^1.1.0",
|
|
57
|
+
"@fabricorg/platform-host": "^5.0.0"
|
|
58
|
+
},
|
|
43
59
|
"scripts": {
|
|
44
60
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
45
61
|
"build": "tsup",
|