@x12i/memorix-service 3.6.2 → 3.6.4
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/README.md +8 -0
- package/dist/access-gate.d.ts +10 -0
- package/dist/access-gate.d.ts.map +1 -1
- package/dist/access-gate.js +38 -1
- package/dist/access-gate.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +2 -0
- package/dist/app.js.map +1 -1
- package/dist/blob-store/types.js +1 -1
- package/dist/blob-store/types.js.map +1 -1
- package/dist/callback-grant.d.ts.map +1 -1
- package/dist/callback-grant.js +10 -6
- package/dist/callback-grant.js.map +1 -1
- package/dist/catalog/catalog-service.js +1 -1
- package/dist/catalog/catalog-service.js.map +1 -1
- package/dist/catalog-bridge.d.ts.map +1 -1
- package/dist/catalog-bridge.js +74 -61
- package/dist/catalog-bridge.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/connector-catalog.d.ts +8 -3
- package/dist/connector-catalog.d.ts.map +1 -1
- package/dist/connector-catalog.js +66 -93
- package/dist/connector-catalog.js.map +1 -1
- package/dist/generic-connectors.d.ts +39 -1
- package/dist/generic-connectors.d.ts.map +1 -1
- package/dist/generic-connectors.js +142 -3
- package/dist/generic-connectors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs-scope.d.ts +1 -0
- package/dist/jobs-scope.d.ts.map +1 -1
- package/dist/jobs-scope.js +5 -4
- package/dist/jobs-scope.js.map +1 -1
- package/dist/mgc-landing-stores.d.ts +94 -0
- package/dist/mgc-landing-stores.d.ts.map +1 -0
- package/dist/mgc-landing-stores.js +174 -0
- package/dist/mgc-landing-stores.js.map +1 -0
- package/dist/optional-companion-url.d.ts +1 -1
- package/dist/optional-companion-url.js +1 -1
- package/dist/pipeline-compile.d.ts +1 -1
- package/dist/pipeline-compile.js +1 -1
- package/dist/platform.d.ts +17 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +56 -8
- package/dist/platform.js.map +1 -1
- package/dist/routes/connector-invocations.d.ts.map +1 -1
- package/dist/routes/connector-invocations.js +6 -1
- package/dist/routes/connector-invocations.js.map +1 -1
- package/dist/routes/connector-ops.d.ts +2 -1
- package/dist/routes/connector-ops.d.ts.map +1 -1
- package/dist/routes/connector-ops.js +8 -5
- package/dist/routes/connector-ops.js.map +1 -1
- package/dist/routes/data.d.ts.map +1 -1
- package/dist/routes/data.js +11 -12
- package/dist/routes/data.js.map +1 -1
- package/dist/routes/jobs.d.ts.map +1 -1
- package/dist/routes/jobs.js +46 -21
- package/dist/routes/jobs.js.map +1 -1
- package/dist/routes/memory.d.ts.map +1 -1
- package/dist/routes/memory.js +187 -90
- package/dist/routes/memory.js.map +1 -1
- package/dist/routes/mgc-landing.d.ts +7 -0
- package/dist/routes/mgc-landing.d.ts.map +1 -0
- package/dist/routes/mgc-landing.js +177 -0
- package/dist/routes/mgc-landing.js.map +1 -0
- package/dist/scope.d.ts +23 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +13 -1
- package/dist/scope.js.map +1 -1
- package/dist/write-precondition.d.ts +14 -0
- package/dist/write-precondition.d.ts.map +1 -0
- package/dist/write-precondition.js +41 -0
- package/dist/write-precondition.js.map +1 -0
- package/package.json +1 -2
package/dist/jobs-scope.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServiceError } from "./errors.js";
|
|
2
|
+
import { normalizeOrgId } from "./scope.js";
|
|
2
3
|
function header(headers, name) {
|
|
3
4
|
const v = headers[name] ?? headers[name.toLowerCase()];
|
|
4
5
|
if (Array.isArray(v))
|
|
@@ -31,8 +32,8 @@ export function resolveJobsScope(req) {
|
|
|
31
32
|
orgId = null;
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
const fromQuery = typeof q.orgId === "string" ? q.orgId
|
|
35
|
-
const fromHeader = (orgHeader
|
|
35
|
+
const fromQuery = typeof q.orgId === "string" ? normalizeOrgId(q.orgId) : "";
|
|
36
|
+
const fromHeader = orgHeader ? normalizeOrgId(orgHeader) : "";
|
|
36
37
|
orgId = fromQuery || fromHeader || null;
|
|
37
38
|
if (!orgId) {
|
|
38
39
|
throw new ServiceError("SCOPE_INVALID", "orgId required unless x-memorix-jobs-org-scope: all", 400);
|
|
@@ -61,7 +62,7 @@ export function resolveJobsScope(req) {
|
|
|
61
62
|
export function resolveConcreteOrgId(scope, query) {
|
|
62
63
|
if (scope.orgId)
|
|
63
64
|
return scope.orgId;
|
|
64
|
-
const fromQuery = typeof query?.orgId === "string" ? query.orgId
|
|
65
|
+
const fromQuery = typeof query?.orgId === "string" ? normalizeOrgId(query.orgId) : "";
|
|
65
66
|
if (!fromQuery) {
|
|
66
67
|
throw new ServiceError("SCOPE_INVALID", "orgId query required when organization scope is all", 400);
|
|
67
68
|
}
|
|
@@ -76,7 +77,7 @@ export function agentMatches(rowAgentIds, filter) {
|
|
|
76
77
|
}
|
|
77
78
|
export function toMemorixScope(orgId, agentIds) {
|
|
78
79
|
return {
|
|
79
|
-
orgId,
|
|
80
|
+
orgId: normalizeOrgId(orgId),
|
|
80
81
|
agentIds: agentIds?.length ? agentIds : ["opx"],
|
|
81
82
|
};
|
|
82
83
|
}
|
package/dist/jobs-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-scope.js","sourceRoot":"","sources":["../src/jobs-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"jobs-scope.js","sourceRoot":"","sources":["../src/jobs-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAa5C,SAAS,MAAM,CACb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AC;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type RawRecordDoc = {
|
|
2
|
+
identity: string;
|
|
3
|
+
collection: string;
|
|
4
|
+
objectType: string;
|
|
5
|
+
payload: unknown;
|
|
6
|
+
fetchedAt: string;
|
|
7
|
+
ttlSeconds: number;
|
|
8
|
+
connectorId: string;
|
|
9
|
+
definitionHash?: string;
|
|
10
|
+
provenance: "cache" | "source";
|
|
11
|
+
orgId: string;
|
|
12
|
+
streamId?: string;
|
|
13
|
+
};
|
|
14
|
+
export type RawRecordStore = {
|
|
15
|
+
put(doc: RawRecordDoc): Promise<RawRecordDoc>;
|
|
16
|
+
get(orgId: string, collection: string, identity: string): Promise<RawRecordDoc | null>;
|
|
17
|
+
list(orgId: string, collection: string, limit?: number): Promise<RawRecordDoc[]>;
|
|
18
|
+
};
|
|
19
|
+
export type TargetEffectState = "not_applied" | "unknown" | "applied";
|
|
20
|
+
export type TargetItemReceiptStatus = "claimed" | "in_progress" | "completed" | "released";
|
|
21
|
+
export type TargetItemReceiptDoc = {
|
|
22
|
+
orgId: string;
|
|
23
|
+
destinationId: string;
|
|
24
|
+
idempotencyKey: string;
|
|
25
|
+
status: TargetItemReceiptStatus;
|
|
26
|
+
claimedAt?: string;
|
|
27
|
+
completedAt?: string;
|
|
28
|
+
releasedAt?: string;
|
|
29
|
+
workId?: string;
|
|
30
|
+
invocationId?: string;
|
|
31
|
+
providerResourceId?: string;
|
|
32
|
+
reused?: boolean;
|
|
33
|
+
reconciled?: boolean;
|
|
34
|
+
retryable?: boolean;
|
|
35
|
+
effectState?: TargetEffectState;
|
|
36
|
+
failure?: {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
receipt?: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
export type TargetItemReceiptStore = {
|
|
43
|
+
lookup(orgId: string, destinationId: string, idempotencyKey: string): Promise<TargetItemReceiptDoc | null>;
|
|
44
|
+
claim(input: {
|
|
45
|
+
orgId: string;
|
|
46
|
+
destinationId: string;
|
|
47
|
+
idempotencyKey: string;
|
|
48
|
+
workId?: string;
|
|
49
|
+
invocationId?: string;
|
|
50
|
+
}): Promise<TargetItemReceiptDoc>;
|
|
51
|
+
complete(input: {
|
|
52
|
+
orgId: string;
|
|
53
|
+
destinationId: string;
|
|
54
|
+
idempotencyKey: string;
|
|
55
|
+
providerResourceId?: string;
|
|
56
|
+
reused?: boolean;
|
|
57
|
+
reconciled?: boolean;
|
|
58
|
+
receipt?: Record<string, unknown>;
|
|
59
|
+
}): Promise<TargetItemReceiptDoc>;
|
|
60
|
+
release(input: {
|
|
61
|
+
orgId: string;
|
|
62
|
+
destinationId: string;
|
|
63
|
+
idempotencyKey: string;
|
|
64
|
+
retryable?: boolean;
|
|
65
|
+
effectState?: TargetEffectState;
|
|
66
|
+
failure?: {
|
|
67
|
+
code: string;
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
}): Promise<TargetItemReceiptDoc>;
|
|
71
|
+
};
|
|
72
|
+
export type DeliveryArtifactDoc = {
|
|
73
|
+
ref: string;
|
|
74
|
+
orgId: string;
|
|
75
|
+
contentType: string;
|
|
76
|
+
bytes: Buffer;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
};
|
|
79
|
+
export type DeliveryArtifactStore = {
|
|
80
|
+
put(doc: DeliveryArtifactDoc): Promise<void>;
|
|
81
|
+
get(orgId: string, ref: string): Promise<DeliveryArtifactDoc | null>;
|
|
82
|
+
};
|
|
83
|
+
export declare function createInMemoryRawRecordStore(): RawRecordStore;
|
|
84
|
+
export declare function createInMemoryTargetItemReceiptStore(): TargetItemReceiptStore;
|
|
85
|
+
export declare function createInMemoryDeliveryArtifactStore(): DeliveryArtifactStore;
|
|
86
|
+
/** Decode the opaque invocation grant MGC echoes on landing callbacks. */
|
|
87
|
+
export declare function decodeLandingGrantToken(token: string): {
|
|
88
|
+
grantId: string;
|
|
89
|
+
invocationId: string;
|
|
90
|
+
orgId: string;
|
|
91
|
+
expiresAt: string;
|
|
92
|
+
operations: string[];
|
|
93
|
+
} | null;
|
|
94
|
+
//# sourceMappingURL=mgc-landing-stores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgc-landing-stores.d.ts","sourceRoot":"","sources":["../src/mgc-landing-stores.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACvF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;CAClF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,aAAa,GACb,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,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AE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GAAG,IAAI,CA4BP"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grant-scoped MGC landing stores hosted by memorix-service.
|
|
3
|
+
* Canonical types also live in @x12i/memorix-memory (publish together).
|
|
4
|
+
*/
|
|
5
|
+
import { normalizeOrgId } from "./scope.js";
|
|
6
|
+
function rawKey(orgId, collection, identity) {
|
|
7
|
+
return `${orgId}\0${collection}\0${identity}`;
|
|
8
|
+
}
|
|
9
|
+
export function createInMemoryRawRecordStore() {
|
|
10
|
+
const byKey = new Map();
|
|
11
|
+
return {
|
|
12
|
+
async put(doc) {
|
|
13
|
+
const stored = { ...doc };
|
|
14
|
+
byKey.set(rawKey(doc.orgId, doc.collection, doc.identity), stored);
|
|
15
|
+
return { ...stored };
|
|
16
|
+
},
|
|
17
|
+
async get(orgId, collection, identity) {
|
|
18
|
+
const found = byKey.get(rawKey(orgId, collection, identity));
|
|
19
|
+
return found ? { ...found } : null;
|
|
20
|
+
},
|
|
21
|
+
async list(orgId, collection, limit = 200) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const doc of byKey.values()) {
|
|
24
|
+
if (doc.orgId === orgId && doc.collection === collection) {
|
|
25
|
+
out.push({ ...doc });
|
|
26
|
+
}
|
|
27
|
+
if (out.length >= limit)
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function receiptKey(orgId, destinationId, idempotencyKey) {
|
|
35
|
+
return `${orgId}\0${destinationId}\0${idempotencyKey}`;
|
|
36
|
+
}
|
|
37
|
+
function sanitizeFailure(failure) {
|
|
38
|
+
if (!failure)
|
|
39
|
+
return undefined;
|
|
40
|
+
return {
|
|
41
|
+
code: String(failure.code ?? "TARGET_ITEM_FAILED").slice(0, 120),
|
|
42
|
+
message: String(failure.message ?? "")
|
|
43
|
+
.replace(/(Bearer\s+)\S+/gi, "$1[REDACTED]")
|
|
44
|
+
.replace(/(api[_-]?key|token|password|secret)\s*[:=]\s*\S+/gi, "$1=[REDACTED]")
|
|
45
|
+
.slice(0, 500),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createInMemoryTargetItemReceiptStore() {
|
|
49
|
+
const byKey = new Map();
|
|
50
|
+
return {
|
|
51
|
+
async lookup(orgId, destinationId, idempotencyKey) {
|
|
52
|
+
const found = byKey.get(receiptKey(orgId, destinationId, idempotencyKey));
|
|
53
|
+
return found ? { ...found } : null;
|
|
54
|
+
},
|
|
55
|
+
async claim(input) {
|
|
56
|
+
const k = receiptKey(input.orgId, input.destinationId, input.idempotencyKey);
|
|
57
|
+
const existing = byKey.get(k);
|
|
58
|
+
if (existing?.status === "completed")
|
|
59
|
+
return { ...existing };
|
|
60
|
+
if (existing?.status === "claimed" || existing?.status === "in_progress") {
|
|
61
|
+
return { ...existing, status: "in_progress" };
|
|
62
|
+
}
|
|
63
|
+
const now = new Date().toISOString();
|
|
64
|
+
const doc = {
|
|
65
|
+
orgId: input.orgId,
|
|
66
|
+
destinationId: input.destinationId,
|
|
67
|
+
idempotencyKey: input.idempotencyKey,
|
|
68
|
+
status: "claimed",
|
|
69
|
+
claimedAt: now,
|
|
70
|
+
workId: input.workId,
|
|
71
|
+
invocationId: input.invocationId,
|
|
72
|
+
};
|
|
73
|
+
byKey.set(k, doc);
|
|
74
|
+
return { ...doc };
|
|
75
|
+
},
|
|
76
|
+
async complete(input) {
|
|
77
|
+
const k = receiptKey(input.orgId, input.destinationId, input.idempotencyKey);
|
|
78
|
+
const existing = byKey.get(k);
|
|
79
|
+
if (existing?.status === "completed")
|
|
80
|
+
return { ...existing };
|
|
81
|
+
const now = new Date().toISOString();
|
|
82
|
+
const doc = {
|
|
83
|
+
...(existing ?? {
|
|
84
|
+
orgId: input.orgId,
|
|
85
|
+
destinationId: input.destinationId,
|
|
86
|
+
idempotencyKey: input.idempotencyKey,
|
|
87
|
+
}),
|
|
88
|
+
status: "completed",
|
|
89
|
+
completedAt: now,
|
|
90
|
+
providerResourceId: input.providerResourceId,
|
|
91
|
+
reused: input.reused,
|
|
92
|
+
reconciled: input.reconciled,
|
|
93
|
+
effectState: "applied",
|
|
94
|
+
retryable: false,
|
|
95
|
+
receipt: input.receipt ? { ...input.receipt } : existing?.receipt,
|
|
96
|
+
};
|
|
97
|
+
byKey.set(k, doc);
|
|
98
|
+
return { ...doc };
|
|
99
|
+
},
|
|
100
|
+
async release(input) {
|
|
101
|
+
const k = receiptKey(input.orgId, input.destinationId, input.idempotencyKey);
|
|
102
|
+
const existing = byKey.get(k);
|
|
103
|
+
if (existing?.status === "completed")
|
|
104
|
+
return { ...existing };
|
|
105
|
+
const now = new Date().toISOString();
|
|
106
|
+
const doc = {
|
|
107
|
+
...(existing ?? {
|
|
108
|
+
orgId: input.orgId,
|
|
109
|
+
destinationId: input.destinationId,
|
|
110
|
+
idempotencyKey: input.idempotencyKey,
|
|
111
|
+
}),
|
|
112
|
+
status: "released",
|
|
113
|
+
releasedAt: now,
|
|
114
|
+
retryable: input.retryable ?? true,
|
|
115
|
+
effectState: input.effectState ?? "not_applied",
|
|
116
|
+
failure: sanitizeFailure(input.failure),
|
|
117
|
+
};
|
|
118
|
+
byKey.set(k, doc);
|
|
119
|
+
return { ...doc };
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function artifactKey(orgId, ref) {
|
|
124
|
+
return `${orgId}\0${ref}`;
|
|
125
|
+
}
|
|
126
|
+
export function createInMemoryDeliveryArtifactStore() {
|
|
127
|
+
const byKey = new Map();
|
|
128
|
+
return {
|
|
129
|
+
async put(doc) {
|
|
130
|
+
byKey.set(artifactKey(doc.orgId, doc.ref), {
|
|
131
|
+
...doc,
|
|
132
|
+
bytes: Buffer.from(doc.bytes),
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
async get(orgId, ref) {
|
|
136
|
+
const found = byKey.get(artifactKey(orgId, ref));
|
|
137
|
+
if (!found)
|
|
138
|
+
return null;
|
|
139
|
+
return { ...found, bytes: Buffer.from(found.bytes) };
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** Decode the opaque invocation grant MGC echoes on landing callbacks. */
|
|
144
|
+
export function decodeLandingGrantToken(token) {
|
|
145
|
+
const raw = token.trim();
|
|
146
|
+
if (!raw)
|
|
147
|
+
return null;
|
|
148
|
+
try {
|
|
149
|
+
const json = Buffer.from(raw, "base64url").toString("utf8");
|
|
150
|
+
const parsed = JSON.parse(json);
|
|
151
|
+
if (typeof parsed.grantId !== "string" ||
|
|
152
|
+
typeof parsed.invocationId !== "string" ||
|
|
153
|
+
typeof parsed.orgId !== "string" ||
|
|
154
|
+
typeof parsed.expiresAt !== "string") {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const orgId = normalizeOrgId(parsed.orgId);
|
|
158
|
+
if (!orgId)
|
|
159
|
+
return null;
|
|
160
|
+
return {
|
|
161
|
+
grantId: parsed.grantId,
|
|
162
|
+
invocationId: parsed.invocationId,
|
|
163
|
+
orgId,
|
|
164
|
+
expiresAt: parsed.expiresAt,
|
|
165
|
+
operations: Array.isArray(parsed.operations)
|
|
166
|
+
? parsed.operations.filter((s) => typeof s === "string")
|
|
167
|
+
: [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=mgc-landing-stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgc-landing-stores.js","sourceRoot":"","sources":["../src/mgc-landing-stores.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA8F5C,SAAS,MAAM,CAAC,KAAa,EAAE,UAAkB,EAAE,QAAgB;IACjE,OAAO,GAAG,KAAK,K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vC,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;YAChC,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,EACpC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,KAAK;YACL,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;gBAC1C,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;gBACrE,CAAC,CAAC,EAAE;SACP,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Soft-skip / fail-closed policy for optional HTTP pipeline companions
|
|
3
|
-
* (Exellix connectors, Neo vulnerability workers,
|
|
3
|
+
* (Exellix connectors, Neo vulnerability workers, Nexum-style companion URLs).
|
|
4
4
|
*
|
|
5
5
|
* - URL unset → soft-skip unless required env/flag is set
|
|
6
6
|
* - URL set → fail-closed on transport or failed envelope status
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Soft-skip / fail-closed policy for optional HTTP pipeline companions
|
|
3
|
-
* (Exellix connectors, Neo vulnerability workers,
|
|
3
|
+
* (Exellix connectors, Neo vulnerability workers, Nexum-style companion URLs).
|
|
4
4
|
*
|
|
5
5
|
* - URL unset → soft-skip unless required env/flag is set
|
|
6
6
|
* - URL set → fail-closed on transport or failed envelope status
|
|
@@ -63,7 +63,7 @@ export declare function resolveNexumWorkerUrl(): string;
|
|
|
63
63
|
/**
|
|
64
64
|
* Resolve analyze-step worker endpoint.
|
|
65
65
|
* knowx-extract → APS AI sim only when KNOWX_AI_SIM=1 (test-only);
|
|
66
|
-
* nexum → MEMORIX_NEXUM_URL / :7500 (never KnowX
|
|
66
|
+
* nexum → MEMORIX_NEXUM_URL / :7500 (never KnowX);
|
|
67
67
|
* otherwise KnowX control-plane worker (or per-service endpointEnv).
|
|
68
68
|
*/
|
|
69
69
|
export declare function resolveKnowxServiceEndpoint(serviceId: string, opts?: {
|
package/dist/pipeline-compile.js
CHANGED
|
@@ -82,7 +82,7 @@ export function resolveNexumWorkerUrl() {
|
|
|
82
82
|
/**
|
|
83
83
|
* Resolve analyze-step worker endpoint.
|
|
84
84
|
* knowx-extract → APS AI sim only when KNOWX_AI_SIM=1 (test-only);
|
|
85
|
-
* nexum → MEMORIX_NEXUM_URL / :7500 (never KnowX
|
|
85
|
+
* nexum → MEMORIX_NEXUM_URL / :7500 (never KnowX);
|
|
86
86
|
* otherwise KnowX control-plane worker (or per-service endpointEnv).
|
|
87
87
|
*/
|
|
88
88
|
export function resolveKnowxServiceEndpoint(serviceId, opts) {
|
package/dist/platform.d.ts
CHANGED
|
@@ -12,8 +12,9 @@ import { type IntelligenceArtifactPersistence } from "@x12i/memorix-intelligence
|
|
|
12
12
|
import { type RunLedger, type PipelineRuntime } from "@x12i/memorix-pipeline/v2";
|
|
13
13
|
import { type OperationalStores } from "@x12i/memorix-pipeline-runtime";
|
|
14
14
|
import { ServiceError } from "./errors.js";
|
|
15
|
+
import { type DeliveryArtifactStore, type RawRecordStore, type TargetItemReceiptStore } from "./mgc-landing-stores.js";
|
|
15
16
|
import { type ServiceCatalog } from "./catalog-bridge.js";
|
|
16
|
-
import type
|
|
17
|
+
import { type MemorixScope } from "./scope.js";
|
|
17
18
|
import { type IsolationSession } from "./isolation.js";
|
|
18
19
|
import { type MagitPackService } from "./magit/magit-pack-service.js";
|
|
19
20
|
import { type GenericConnectorsConfig } from "./generic-connectors.js";
|
|
@@ -74,6 +75,12 @@ export type MemorixPlatform = {
|
|
|
74
75
|
invocationLedger: InvocationLedger;
|
|
75
76
|
/** Org destination definitions + deliver receipts. */
|
|
76
77
|
destinationStore: DestinationStore;
|
|
78
|
+
/** Grant-scoped `{objectType}-raw` cache for MGC MCP. */
|
|
79
|
+
rawRecordStore: RawRecordStore;
|
|
80
|
+
/** Per-item claim/complete/release ledger during /v1/deliver. */
|
|
81
|
+
targetItemReceipts: TargetItemReceiptStore;
|
|
82
|
+
/** Binary artifacts for target `data-ref` resolution. */
|
|
83
|
+
deliveryArtifacts: DeliveryArtifactStore;
|
|
77
84
|
/** Target deliverer (remote MGC target host). */
|
|
78
85
|
deliverer: MemoryDeliverer;
|
|
79
86
|
/** Generic connectors platform env (MGC zone). */
|
|
@@ -95,6 +102,10 @@ export type MemorixPlatform = {
|
|
|
95
102
|
* Mongo when available; in-memory fallback in no-mongo dev.
|
|
96
103
|
*/
|
|
97
104
|
operationalStoresFor(orgId: string): OperationalStores;
|
|
105
|
+
/**
|
|
106
|
+
* Canonical org id for storage keys (trim + toLocaleLowerCase("en-US")).
|
|
107
|
+
*/
|
|
108
|
+
resolveOrgId(orgId: string): string;
|
|
98
109
|
/**
|
|
99
110
|
* Known operational org ids: in-memory caches union Mongo `*_operational` DBs when available.
|
|
100
111
|
* Used by Jobs Manager unscoped (All orgs) list/overview fan-out.
|
|
@@ -103,6 +114,11 @@ export type MemorixPlatform = {
|
|
|
103
114
|
intelligenceArtifactsFor(orgId: string): IntelligenceArtifactPersistence;
|
|
104
115
|
/** Fail-closed: throws if ports cannot be constructed. */
|
|
105
116
|
portsFor(scope: MemorixScope): OrgPorts;
|
|
117
|
+
/**
|
|
118
|
+
* Drop cached OrgPorts so the next portsFor rebuilds writers/readers/pipelines
|
|
119
|
+
* against current installed metadata (call after metadata install / rehydrate).
|
|
120
|
+
*/
|
|
121
|
+
invalidateOrgPortsCache(): void;
|
|
106
122
|
/**
|
|
107
123
|
* Org runtime source registry (folder sources, etc.).
|
|
108
124
|
* Works with Mongo when available; in-memory fallback in no-mongo dev.
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAeL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAGL,KAAK,+BAA+B,EACrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAQL,KAAK,SAAS,EACd,KAAK,eAAe,EAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CA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AAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,IAAI,CAAC;IACxF;;;OAGG;IACH,mBAAmB,CAAC,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,IAAI,CAAC;IAChE;;;OAGG;IACH,gCAAgC,CAAC,IAAI,CAAC,EAAE;QACtC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;KACpF,GAAG,MAAM,IAAI,CAAC;IACf,+DAA+D;IAC/D,+BAA+B,CAC7B,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,cAAc,CAAC,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;KACpF,GACA,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3D,CAAC;AAEF,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,eAAe,CAAC,CAooC1B"}
|
package/dist/platform.js
CHANGED
|
@@ -14,11 +14,13 @@ import { createIntelligenceArtifactPersistence, createMongoRunLedger, } from "@x
|
|
|
14
14
|
import { createMongoRunLedger as createPipelineLedger, createMemoryRunLedger, createPipelineRuntime, createLivePortRegistry, loadDataRef, tickWork, promoteHeldRuns, } from "@x12i/memorix-pipeline/v2";
|
|
15
15
|
import { createMongoOperationalStores, createMemoryOperationalStores, ensureOperationalIndexes, } from "@x12i/memorix-pipeline-runtime";
|
|
16
16
|
import { ServiceError } from "./errors.js";
|
|
17
|
+
import { createInMemoryDeliveryArtifactStore, createInMemoryRawRecordStore, createInMemoryTargetItemReceiptStore, } from "./mgc-landing-stores.js";
|
|
17
18
|
import { memoryPullFetch, serviceInvokePorts, setStepProgressReporter } from "./live.js";
|
|
18
19
|
import { resolveKnowxWorkerBaseUrl } from "./pipeline-compile.js";
|
|
19
20
|
import { createRemoteOrLocalPort, createRunPipelinePort, createRunxPort, } from "./pipeline-ports.js";
|
|
20
21
|
import { createMongoMetadataStore, } from "./mongo-metadata-store.js";
|
|
21
22
|
import { catalogFromMetadataClient, relationshipMetadataResolver, } from "./catalog-bridge.js";
|
|
23
|
+
import { normalizeOrgId } from "./scope.js";
|
|
22
24
|
import { assertSafeSandboxOrgId, recordCreatedDatabase, } from "./isolation.js";
|
|
23
25
|
import { createMagitPackService, isMetadataMagitEnabled, magitPackageTypeIdConfigured, magitPackageTypeIdForDiagnostics, magitStoreSelectorConfigured, magitTypedStoreConfigured, resolveMagitCatalogTenant, resolveMagitRepoRootParent, resolveMagitStorageTokenEnv, } from "./magit/magit-pack-service.js";
|
|
24
26
|
import { loadGenericConnectorsConfig, } from "./generic-connectors.js";
|
|
@@ -76,6 +78,9 @@ export async function createMemorixPlatform(deps) {
|
|
|
76
78
|
});
|
|
77
79
|
const invocationLedger = createInMemoryInvocationLedger();
|
|
78
80
|
const destinationStore = createInMemoryDestinationStore();
|
|
81
|
+
const rawRecordStore = createInMemoryRawRecordStore();
|
|
82
|
+
const targetItemReceipts = createInMemoryTargetItemReceiptStore();
|
|
83
|
+
const deliveryArtifacts = createInMemoryDeliveryArtifactStore();
|
|
79
84
|
const genericConnectors = loadGenericConnectorsConfig();
|
|
80
85
|
const deliverer = createMemoryDeliverer({
|
|
81
86
|
store: destinationStore,
|
|
@@ -149,7 +154,27 @@ export async function createMemorixPlatform(deps) {
|
|
|
149
154
|
else {
|
|
150
155
|
metadata = createMetadataClient(createInMemoryMetadataStore());
|
|
151
156
|
}
|
|
157
|
+
function invalidateOrgPortsCache() {
|
|
158
|
+
portsCache.clear();
|
|
159
|
+
}
|
|
160
|
+
function resolveOrgId(orgId) {
|
|
161
|
+
const id = normalizeOrgId(orgId);
|
|
162
|
+
if (!id) {
|
|
163
|
+
throw new ServiceError("SCOPE_INVALID", "orgId is required and must be a non-empty string", 400);
|
|
164
|
+
}
|
|
165
|
+
return id;
|
|
166
|
+
}
|
|
167
|
+
// Metadata install mutates object-types/services used by OrgPorts. Clear the
|
|
168
|
+
// ports cache so agent-alone scopes do not keep a pre-install empty catalog.
|
|
169
|
+
const metadataInstall = metadata.install.bind(metadata);
|
|
170
|
+
metadata.install = ((pack, opts) => {
|
|
171
|
+
const result = metadataInstall(pack, opts);
|
|
172
|
+
if (result.ok)
|
|
173
|
+
invalidateOrgPortsCache();
|
|
174
|
+
return result;
|
|
175
|
+
});
|
|
152
176
|
function operationalDbFor(orgId) {
|
|
177
|
+
orgId = resolveOrgId(orgId);
|
|
153
178
|
if (!client) {
|
|
154
179
|
throw new ServiceError("DURABLE_STORE_REQUIRED", "operational Mongo DB is required for this operation", 503);
|
|
155
180
|
}
|
|
@@ -163,12 +188,14 @@ export async function createMemorixPlatform(deps) {
|
|
|
163
188
|
return client.db(`${orgId}_operational`);
|
|
164
189
|
}
|
|
165
190
|
function metadataDbFor(orgId) {
|
|
191
|
+
orgId = resolveOrgId(orgId);
|
|
166
192
|
if (!client) {
|
|
167
193
|
throw new ServiceError("DURABLE_STORE_REQUIRED", "mongo required", 503);
|
|
168
194
|
}
|
|
169
195
|
return client.db(`${orgId}_metadata`);
|
|
170
196
|
}
|
|
171
197
|
function pipelineLedgerFor(orgId) {
|
|
198
|
+
orgId = resolveOrgId(orgId);
|
|
172
199
|
const existing = ledgers.get(orgId);
|
|
173
200
|
if (existing)
|
|
174
201
|
return existing;
|
|
@@ -182,6 +209,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
182
209
|
return ledger;
|
|
183
210
|
}
|
|
184
211
|
function operationalStoresFor(orgId) {
|
|
212
|
+
orgId = resolveOrgId(orgId);
|
|
185
213
|
const existing = operationalStoresByOrg.get(orgId);
|
|
186
214
|
if (existing)
|
|
187
215
|
return existing;
|
|
@@ -200,10 +228,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
200
228
|
return stores;
|
|
201
229
|
}
|
|
202
230
|
async function listKnownOperationalOrgIds() {
|
|
203
|
-
const
|
|
204
|
-
...operationalStoresByOrg.keys(),
|
|
205
|
-
...ledgers.keys(),
|
|
206
|
-
]);
|
|
231
|
+
const ids = new Set();
|
|
207
232
|
if (client) {
|
|
208
233
|
try {
|
|
209
234
|
const dbs = await client.db().admin().listDatabases();
|
|
@@ -212,15 +237,24 @@ export async function createMemorixPlatform(deps) {
|
|
|
212
237
|
if (!name.endsWith("_operational"))
|
|
213
238
|
continue;
|
|
214
239
|
const orgId = name.slice(0, -"_operational".length);
|
|
215
|
-
|
|
216
|
-
|
|
240
|
+
const n = normalizeOrgId(orgId);
|
|
241
|
+
if (n)
|
|
242
|
+
ids.add(n);
|
|
217
243
|
}
|
|
218
244
|
}
|
|
219
245
|
catch {
|
|
220
|
-
// Discovery is best-effort;
|
|
246
|
+
// Discovery is best-effort; in-memory keys still apply.
|
|
221
247
|
}
|
|
222
248
|
}
|
|
223
|
-
|
|
249
|
+
for (const id of [
|
|
250
|
+
...operationalStoresByOrg.keys(),
|
|
251
|
+
...ledgers.keys(),
|
|
252
|
+
]) {
|
|
253
|
+
const n = normalizeOrgId(id);
|
|
254
|
+
if (n)
|
|
255
|
+
ids.add(n);
|
|
256
|
+
}
|
|
257
|
+
return [...ids].sort((a, b) => a.localeCompare(b));
|
|
224
258
|
}
|
|
225
259
|
// KnowX chunked extract reports mid-step progress onto the running attempt.
|
|
226
260
|
setStepProgressReporter(async (orgId, attemptId, progress) => {
|
|
@@ -233,6 +267,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
233
267
|
});
|
|
234
268
|
});
|
|
235
269
|
function intelligenceArtifactsFor(orgId) {
|
|
270
|
+
orgId = resolveOrgId(orgId);
|
|
236
271
|
const existing = intelStores.get(orgId);
|
|
237
272
|
if (existing)
|
|
238
273
|
return existing;
|
|
@@ -248,6 +283,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
248
283
|
return store;
|
|
249
284
|
}
|
|
250
285
|
function orgRuntimeSourcesFor(orgId) {
|
|
286
|
+
orgId = resolveOrgId(orgId);
|
|
251
287
|
const existing = orgRuntimeSourceStores.get(orgId);
|
|
252
288
|
if (existing)
|
|
253
289
|
return existing;
|
|
@@ -258,6 +294,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
258
294
|
return store;
|
|
259
295
|
}
|
|
260
296
|
function connectorOpOverridesFor(orgId) {
|
|
297
|
+
orgId = resolveOrgId(orgId);
|
|
261
298
|
const existing = mcoOverrideStores.get(orgId);
|
|
262
299
|
if (existing)
|
|
263
300
|
return existing;
|
|
@@ -278,6 +315,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
278
315
|
return store;
|
|
279
316
|
}
|
|
280
317
|
function connectorOpAttemptsFor(orgId) {
|
|
318
|
+
orgId = resolveOrgId(orgId);
|
|
281
319
|
const existing = mcoAttemptStores.get(orgId);
|
|
282
320
|
if (existing)
|
|
283
321
|
return existing;
|
|
@@ -298,6 +336,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
298
336
|
return store;
|
|
299
337
|
}
|
|
300
338
|
function integrationInstancesFor(orgId) {
|
|
339
|
+
orgId = resolveOrgId(orgId);
|
|
301
340
|
const existing = integrationStores.get(orgId);
|
|
302
341
|
if (existing)
|
|
303
342
|
return existing;
|
|
@@ -318,6 +357,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
318
357
|
return store;
|
|
319
358
|
}
|
|
320
359
|
function restrictedObjectsFor(orgId) {
|
|
360
|
+
orgId = resolveOrgId(orgId);
|
|
321
361
|
const existing = restrictedStores.get(orgId);
|
|
322
362
|
if (existing)
|
|
323
363
|
return existing;
|
|
@@ -343,6 +383,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
343
383
|
return store;
|
|
344
384
|
}
|
|
345
385
|
function storeOrMemory(map, orgId, label, mongo, memory) {
|
|
386
|
+
orgId = resolveOrgId(orgId);
|
|
346
387
|
const existing = map.get(orgId);
|
|
347
388
|
if (existing)
|
|
348
389
|
return existing;
|
|
@@ -381,6 +422,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
381
422
|
if (!client) {
|
|
382
423
|
throw new ServiceError("CANONICAL_PORT_MISSING", "Mongo client required for data/relationship/memory/pipeline ports", 503);
|
|
383
424
|
}
|
|
425
|
+
scope = { ...scope, orgId: resolveOrgId(scope.orgId) };
|
|
384
426
|
const cacheKey = `${scope.orgId}:${scope.agentIds.join(",")}`;
|
|
385
427
|
const hit = portsCache.get(cacheKey);
|
|
386
428
|
if (hit)
|
|
@@ -837,6 +879,7 @@ export async function createMemorixPlatform(deps) {
|
|
|
837
879
|
async rehydrateMetadata() {
|
|
838
880
|
if (durableMetadata)
|
|
839
881
|
await durableMetadata.hydrate();
|
|
882
|
+
invalidateOrgPortsCache();
|
|
840
883
|
},
|
|
841
884
|
stampAgentLineage(agentId, lineage) {
|
|
842
885
|
if (!durableMetadata)
|
|
@@ -857,6 +900,9 @@ export async function createMemorixPlatform(deps) {
|
|
|
857
900
|
connectorRegistry,
|
|
858
901
|
invocationLedger,
|
|
859
902
|
destinationStore,
|
|
903
|
+
rawRecordStore,
|
|
904
|
+
targetItemReceipts,
|
|
905
|
+
deliveryArtifacts,
|
|
860
906
|
deliverer,
|
|
861
907
|
genericConnectors,
|
|
862
908
|
credorix,
|
|
@@ -864,9 +910,11 @@ export async function createMemorixPlatform(deps) {
|
|
|
864
910
|
metadataDbFor,
|
|
865
911
|
pipelineLedgerFor,
|
|
866
912
|
operationalStoresFor,
|
|
913
|
+
resolveOrgId,
|
|
867
914
|
listKnownOperationalOrgIds,
|
|
868
915
|
intelligenceArtifactsFor,
|
|
869
916
|
portsFor,
|
|
917
|
+
invalidateOrgPortsCache,
|
|
870
918
|
orgRuntimeSourcesFor,
|
|
871
919
|
connectorOpOverridesFor,
|
|
872
920
|
connectorOpAttemptsFor,
|