@principal-ai/subsystems-core 0.51.7 → 0.51.9
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/infra/c4.d.ts.map +1 -1
- package/dist/infra/c4.js +6 -1
- package/dist/infra/c4.js.map +1 -1
- package/dist/infra/wrangler.d.ts +8 -0
- package/dist/infra/wrangler.d.ts.map +1 -1
- package/dist/infra/wrangler.js +61 -0
- package/dist/infra/wrangler.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/storage/topic-share.d.ts +23 -11
- package/dist/storage/topic-share.d.ts.map +1 -1
- package/dist/storage/topic-share.js +19 -7
- package/dist/storage/topic-share.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/infra/c4.ts +6 -1
- package/src/infra/infra.test.ts +60 -0
- package/src/infra/wrangler.ts +55 -0
- package/src/node.ts +1 -1
- package/src/storage/topic-share.test.ts +23 -3
- package/src/storage/topic-share.ts +38 -11
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export * from './types';
|
|
|
14
14
|
export type { DraftTopic, TopicAsset, TopicCreator, TopicSubsystemModelRef, TopicReference, } from './storage/topic-types';
|
|
15
15
|
export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
|
|
16
16
|
export { toSharedTopic } from './storage/topic-share';
|
|
17
|
-
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
|
|
17
|
+
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
|
|
18
18
|
export * from './infra';
|
|
19
19
|
export { validateSubsystemModelCrossField } from './validation';
|
|
20
20
|
export type { SubsystemValidationProblem } from './validation';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIxH,cAAc,SAAS,CAAC;AAKxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI/D,cAAc,cAAc,CAAC"}
|
package/dist/infra/c4.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c4.d.ts","sourceRoot":"","sources":["../../src/infra/c4.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEjF;;;;GAIG;AACH,MAAM,WAAW,i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M,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAiCD,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,MAAM,CAIhG;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,iBAAiB,CAQ7E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG;IAClD,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB,CAsCA"}
|
package/dist/infra/c4.js
CHANGED
|
@@ -18,15 +18,20 @@ const TECHNOLOGY = {
|
|
|
18
18
|
'cloudflare:d1_database': 'Cloudflare D1',
|
|
19
19
|
'cloudflare:kv_namespace': 'Cloudflare KV',
|
|
20
20
|
'cloudflare:queue': 'Cloudflare Queue',
|
|
21
|
+
'cloudflare:container': 'Cloudflare Container',
|
|
22
|
+
// Not read from any config yet — here so a hand-declared resource reads well.
|
|
23
|
+
'neon:database': 'Neon Postgres',
|
|
21
24
|
};
|
|
22
25
|
/** Resource types that run code. Everything else is something code reads or writes. */
|
|
23
|
-
const APPLICATION_TYPES = new Set(['worker']);
|
|
26
|
+
const APPLICATION_TYPES = new Set(['worker', 'container']);
|
|
24
27
|
/** Short suffix that keeps a store's id distinct from a same-named Worker. */
|
|
25
28
|
const ID_SUFFIX = {
|
|
26
29
|
r2_bucket: 'r2',
|
|
27
30
|
d1_database: 'd1',
|
|
28
31
|
kv_namespace: 'kv',
|
|
29
32
|
queue: 'queue',
|
|
33
|
+
container: 'container',
|
|
34
|
+
database: 'db',
|
|
30
35
|
};
|
|
31
36
|
function slug(text) {
|
|
32
37
|
return text
|
package/dist/infra/c4.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c4.js","sourceRoot":"","sources":["../../src/infra/c4.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAsCH,MAAM,UAAU,GAA2B;IACzC,mBAAmB,EAAE,mBAAmB;IACxC,sBAAsB,EAAE,eAAe;IACvC,wBAAwB,EAAE,eAAe;IACzC,yBAAyB,EAAE,eAAe;IAC1C,kBAAkB,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"c4.js","sourceRoot":"","sources":["../../src/infra/c4.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAsCH,MAAM,UAAU,GAA2B;IACzC,mBAAmB,EAAE,mBAAmB;IACxC,sBAAsB,EAAE,eAAe;IACvC,wBAAwB,EAAE,eAAe;IACzC,yBAAyB,EAAE,eAAe;IAC1C,kBAAkB,EAAE,kBAAkB;IACtC,sBAAsB,EAAE,sBAAsB;IAC9C,8EAA8E;IAC9E,eAAe,EAAE,eAAe;CACjC,CAAC;AAEF,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAE3D,8EAA8E;AAC9E,MAAM,SAAS,GAA2B;IACxC,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,SAAS,IAAI,CAAC,IAAY;IACxB,OAAO,IA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dist/infra/wrangler.d.ts
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* binding is the access path between them — named exactly as code names it
|
|
7
7
|
* (`env.TOPIC_BLOBS`), which is what makes the binding a join to trail steps.
|
|
8
8
|
*
|
|
9
|
+
* A `containers` entry is a second deployable unit: a Cloudflare Container the
|
|
10
|
+
* Worker starts and routes to through a Durable Object. The access path is the
|
|
11
|
+
* Durable Object binding of the same class, so that is the edge.
|
|
12
|
+
*
|
|
13
|
+
* Secrets are not in a wrangler config, so anything reached through one (an
|
|
14
|
+
* external Postgres behind `DATABASE_URL`, say) is not declared here and cannot
|
|
15
|
+
* be read from it.
|
|
16
|
+
*
|
|
9
17
|
* Top-level config only. Named environments (`env.staging`) are not read yet.
|
|
10
18
|
*/
|
|
11
19
|
import { type InfraManifest } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/infra/wrangler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/infra/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AA+CjB,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,GAAG,OAAO,EACxB,OAAO,EAAE,sBAAsB,GAC9B,aAAa,CAkHf"}
|
package/dist/infra/wrangler.js
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
* binding is the access path between them — named exactly as code names it
|
|
8
8
|
* (`env.TOPIC_BLOBS`), which is what makes the binding a join to trail steps.
|
|
9
9
|
*
|
|
10
|
+
* A `containers` entry is a second deployable unit: a Cloudflare Container the
|
|
11
|
+
* Worker starts and routes to through a Durable Object. The access path is the
|
|
12
|
+
* Durable Object binding of the same class, so that is the edge.
|
|
13
|
+
*
|
|
14
|
+
* Secrets are not in a wrangler config, so anything reached through one (an
|
|
15
|
+
* external Postgres behind `DATABASE_URL`, say) is not declared here and cannot
|
|
16
|
+
* be read from it.
|
|
17
|
+
*
|
|
10
18
|
* Top-level config only. Named environments (`env.staging`) are not read yet.
|
|
11
19
|
*/
|
|
12
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -110,6 +118,59 @@ function extractWranglerManifest(config, options) {
|
|
|
110
118
|
bindings.push({ from: workerKey, to: key, binding, source: source(pointer) });
|
|
111
119
|
});
|
|
112
120
|
}
|
|
121
|
+
// Containers. Wrangler names the application `<worker>-<class_name>`,
|
|
122
|
+
// lowercased with spaces dashed, unless the entry names it.
|
|
123
|
+
const durableBindings = isObject(root.durable_objects) ? root.durable_objects.bindings : undefined;
|
|
124
|
+
const containers = Array.isArray(root.containers) ? root.containers : [];
|
|
125
|
+
containers.forEach((entry, index) => {
|
|
126
|
+
if (!isObject(entry))
|
|
127
|
+
return;
|
|
128
|
+
const className = str(entry.class_name);
|
|
129
|
+
const name = str(entry.name) ??
|
|
130
|
+
(className ? `${workerName}-${className}`.toLowerCase().replace(/ /g, '-') : undefined);
|
|
131
|
+
if (!name)
|
|
132
|
+
return;
|
|
133
|
+
const pointer = `/containers/${index}`;
|
|
134
|
+
const key = (0, types_1.infraResourceKey)(PROVIDER, 'container', name);
|
|
135
|
+
const attributes = {};
|
|
136
|
+
const image = str(entry.image);
|
|
137
|
+
if (image)
|
|
138
|
+
attributes.image = image;
|
|
139
|
+
const instanceType = str(entry.instance_type);
|
|
140
|
+
if (instanceType)
|
|
141
|
+
attributes.instanceType = instanceType;
|
|
142
|
+
if (typeof entry.max_instances === 'number') {
|
|
143
|
+
attributes.maxInstances = String(entry.max_instances);
|
|
144
|
+
}
|
|
145
|
+
resources.push({
|
|
146
|
+
key,
|
|
147
|
+
provider: PROVIDER,
|
|
148
|
+
resourceType: 'container',
|
|
149
|
+
name,
|
|
150
|
+
label: className ?? name,
|
|
151
|
+
source: source(pointer),
|
|
152
|
+
...(Object.keys(attributes).length > 0 ? { attributes } : {}),
|
|
153
|
+
});
|
|
154
|
+
if (!className || !Array.isArray(durableBindings))
|
|
155
|
+
return;
|
|
156
|
+
durableBindings.forEach((durable, durableIndex) => {
|
|
157
|
+
if (!isObject(durable) || str(durable.class_name) !== className)
|
|
158
|
+
return;
|
|
159
|
+
// A binding with `script_name` reaches a class another Worker defines.
|
|
160
|
+
const script = str(durable.script_name);
|
|
161
|
+
if (script && script !== workerName)
|
|
162
|
+
return;
|
|
163
|
+
const binding = str(durable.name);
|
|
164
|
+
if (!binding)
|
|
165
|
+
return;
|
|
166
|
+
bindings.push({
|
|
167
|
+
from: workerKey,
|
|
168
|
+
to: key,
|
|
169
|
+
binding,
|
|
170
|
+
source: source(`/durable_objects/bindings/${durableIndex}`),
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
113
174
|
return { resources, bindings };
|
|
114
175
|
}
|
|
115
176
|
exports.extractWranglerManifest = extractWranglerManifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler.js","sourceRoot":"","sources":["../../src/infra/wrangler.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"wrangler.js","sourceRoot":"","sources":["../../src/infra/wrangler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,mCAAqC;AACrC,mCAMiB;AAEjB,MAAM,QAAQ,GAAG,YAAY,CAAC;AAI9B,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,GAAG,CAAC,KAAc;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,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E,YAAY,EAAE,EAAE;YAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,SAAS;gBAAE,OAAO;YACxE,uEAAuE;YACvE,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACxC,IAAI,MAAM,IAAI,MAAM,KAAK,UAAU;gBAAE,OAAO;YAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,SAAS;gBACf,EAAE,EAAE,GAAG;gBACP,OAAO;gBACP,MAAM,EAAE,MAAM,CAAC,6BAA6B,YAAY,EAAE,CAAC;aAC5D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC;AArHD,0DAqHC"}
|
package/dist/node.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type { TopicIndexEntry, TopicCreate, TopicUpdate, MigrationResult, } from
|
|
|
13
13
|
export type { DraftTopic, TopicAsset, TopicCreator, TopicSubsystemModelRef, TopicReference, } from './storage/topic-types';
|
|
14
14
|
export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
|
|
15
15
|
export { toSharedTopic } from './storage/topic-share';
|
|
16
|
-
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
|
|
16
|
+
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
|
|
17
17
|
export { OpenCodeEventStore, defaultOpenCodeDBPath } from './opencode/OpenCodeEventStore';
|
|
18
18
|
export type { OpenCodeRawEvent, OpenCodeSessionEvents, OpenCodeEventRetriever, OpenCodeStoreOptions, SessionSummary, SessionListResult, } from './opencode/types';
|
|
19
19
|
export { listAgentSessions, detectAgent, fetchRawEvents } from './opencode/agent-sessions';
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGxH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC1F,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3F,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
* Portable projection of a topic for sharing outside the machine that authored
|
|
3
3
|
* it. Browser-safe (no `node:*`).
|
|
4
4
|
*
|
|
5
|
-
* A {@link DraftTopic} carries fields that only mean something locally:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A {@link DraftTopic} carries fields that only mean something locally: inline
|
|
6
|
+
* image bytes, local asset origins and drawing references. {@link toSharedTopic}
|
|
7
|
+
* drops those and splits image bytes out so a host can upload each one
|
|
8
|
+
* separately.
|
|
9
|
+
*
|
|
10
|
+
* References to subsystem models, C4 sketches and other topics are kept as ids.
|
|
11
|
+
* A share is published under its local id, so a reader resolves the same id
|
|
12
|
+
* against the sharing service instead of the local store. A reference whose
|
|
13
|
+
* target was not shared (or not with the reader) is simply unavailable.
|
|
9
14
|
*/
|
|
10
|
-
import type { DraftTopic, TopicCreator } from './topic-types';
|
|
15
|
+
import type { DraftTopic, TopicCreator, TopicReference, TopicSubsystemModelRef } from './topic-types';
|
|
16
|
+
/** A reference a shared topic can carry. Drawings have no shared form yet. */
|
|
17
|
+
export type SharedTopicReference = Exclude<TopicReference, {
|
|
18
|
+
kind: 'drawing';
|
|
19
|
+
}>;
|
|
11
20
|
/** An image a shared topic refers to. Bytes travel separately, keyed by `id`. */
|
|
12
21
|
export interface SharedTopicAsset {
|
|
13
22
|
/** Content hash; the `asset://<id>` target in the description. */
|
|
@@ -20,9 +29,8 @@ export interface SharedTopicAsset {
|
|
|
20
29
|
alt?: string;
|
|
21
30
|
}
|
|
22
31
|
/**
|
|
23
|
-
* A topic as it leaves the authoring machine. No
|
|
24
|
-
*
|
|
25
|
-
* against `assets`.
|
|
32
|
+
* A topic as it leaves the authoring machine. No inline bytes; `description`
|
|
33
|
+
* is unchanged, so `asset://<id>` links still resolve against `assets`.
|
|
26
34
|
*/
|
|
27
35
|
export interface SharedTopic {
|
|
28
36
|
id: string;
|
|
@@ -36,6 +44,10 @@ export interface SharedTopic {
|
|
|
36
44
|
updatedAt: string;
|
|
37
45
|
createdBy?: TopicCreator;
|
|
38
46
|
assets?: SharedTopicAsset[];
|
|
47
|
+
/** Subsystem models the topic concerns, by share id (same as the local id). */
|
|
48
|
+
subsystemModels?: TopicSubsystemModelRef[];
|
|
49
|
+
/** Attached C4 sketches and related topics, by share id. */
|
|
50
|
+
references?: SharedTopicReference[];
|
|
39
51
|
}
|
|
40
52
|
export interface SharedTopicProjection {
|
|
41
53
|
topic: SharedTopic;
|
|
@@ -49,9 +61,9 @@ export interface SharedTopicProjection {
|
|
|
49
61
|
/**
|
|
50
62
|
* Project a local topic into its shared form.
|
|
51
63
|
*
|
|
52
|
-
* Dropped:
|
|
53
|
-
*
|
|
54
|
-
*
|
|
64
|
+
* Dropped: drawing references (no shared form), each asset's `source` (local
|
|
65
|
+
* Storybook origin) and inline `data`. Assets with neither `data` nor `url`
|
|
66
|
+
* cannot be resolved by a reader and are omitted.
|
|
55
67
|
*/
|
|
56
68
|
export declare function toSharedTopic(topic: DraftTopic): SharedTopicProjection;
|
|
57
69
|
//# sourceMappingURL=topic-share.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic-share.d.ts","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"topic-share.d.ts","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EACZ,cAAc,EACd,sBAAsB,EACvB,MAAM,eAAe,CAAC;AAEvB,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAEhF,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC3C,4DAA4D;IAC5D,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,WAAW,CAAC;IACnB,mFAAmF;IACnF,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,qBAAqB,CAwCtE"}
|
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
* Portable projection of a topic for sharing outside the machine that authored
|
|
4
4
|
* it. Browser-safe (no `node:*`).
|
|
5
5
|
*
|
|
6
|
-
* A {@link DraftTopic} carries fields that only mean something locally:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* A {@link DraftTopic} carries fields that only mean something locally: inline
|
|
7
|
+
* image bytes, local asset origins and drawing references. {@link toSharedTopic}
|
|
8
|
+
* drops those and splits image bytes out so a host can upload each one
|
|
9
|
+
* separately.
|
|
10
|
+
*
|
|
11
|
+
* References to subsystem models, C4 sketches and other topics are kept as ids.
|
|
12
|
+
* A share is published under its local id, so a reader resolves the same id
|
|
13
|
+
* against the sharing service instead of the local store. A reference whose
|
|
14
|
+
* target was not shared (or not with the reader) is simply unavailable.
|
|
10
15
|
*/
|
|
11
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
17
|
exports.toSharedTopic = void 0;
|
|
13
18
|
/**
|
|
14
19
|
* Project a local topic into its shared form.
|
|
15
20
|
*
|
|
16
|
-
* Dropped:
|
|
17
|
-
*
|
|
18
|
-
*
|
|
21
|
+
* Dropped: drawing references (no shared form), each asset's `source` (local
|
|
22
|
+
* Storybook origin) and inline `data`. Assets with neither `data` nor `url`
|
|
23
|
+
* cannot be resolved by a reader and are omitted.
|
|
19
24
|
*/
|
|
20
25
|
function toSharedTopic(topic) {
|
|
21
26
|
const assets = [];
|
|
@@ -34,6 +39,11 @@ function toSharedTopic(topic) {
|
|
|
34
39
|
if (asset.data)
|
|
35
40
|
uploads.push({ id: asset.id, mime: asset.mime, data: asset.data });
|
|
36
41
|
}
|
|
42
|
+
const subsystemModels = (topic.subsystemModels ?? []).map((ref) => ({
|
|
43
|
+
modelId: ref.modelId,
|
|
44
|
+
...(ref.trailIds?.length ? { trailIds: [...ref.trailIds] } : {}),
|
|
45
|
+
}));
|
|
46
|
+
const references = (topic.references ?? []).filter((ref) => ref.kind !== 'drawing');
|
|
37
47
|
return {
|
|
38
48
|
topic: {
|
|
39
49
|
id: topic.id,
|
|
@@ -44,6 +54,8 @@ function toSharedTopic(topic) {
|
|
|
44
54
|
updatedAt: topic.updatedAt,
|
|
45
55
|
...(topic.createdBy ? { createdBy: { ...topic.createdBy } } : {}),
|
|
46
56
|
...(assets.length ? { assets } : {}),
|
|
57
|
+
...(subsystemModels.length ? { subsystemModels } : {}),
|
|
58
|
+
...(references.length ? { references: references.map((ref) => ({ ...ref })) } : {}),
|
|
47
59
|
},
|
|
48
60
|
uploads,
|
|
49
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic-share.js","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"topic-share.js","sourceRoot":"","sources":["../../src/storage/topic-share.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAqDH;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,KAAiB;IAC7C,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,MAAM,OAAO,GAAqC,EAAE,CAAC;IACrD,MAAM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AAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type {
|
|
|
22
22
|
} from './storage/topic-types';
|
|
23
23
|
export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
|
|
24
24
|
export { toSharedTopic } from './storage/topic-share';
|
|
25
|
-
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
|
|
25
|
+
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
|
|
26
26
|
|
|
27
27
|
// Infrastructure-as-code read side: what wrangler / terraform declare, and the
|
|
28
28
|
// shape a live-deployment observation takes. Pure — text and JSON in.
|
package/src/infra/c4.ts
CHANGED
|
@@ -52,10 +52,13 @@ const TECHNOLOGY: Record<string, string> = {
|
|
|
52
52
|
'cloudflare:d1_database': 'Cloudflare D1',
|
|
53
53
|
'cloudflare:kv_namespace': 'Cloudflare KV',
|
|
54
54
|
'cloudflare:queue': 'Cloudflare Queue',
|
|
55
|
+
'cloudflare:container': 'Cloudflare Container',
|
|
56
|
+
// Not read from any config yet — here so a hand-declared resource reads well.
|
|
57
|
+
'neon:database': 'Neon Postgres',
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
/** Resource types that run code. Everything else is something code reads or writes. */
|
|
58
|
-
const APPLICATION_TYPES = new Set(['worker']);
|
|
61
|
+
const APPLICATION_TYPES = new Set(['worker', 'container']);
|
|
59
62
|
|
|
60
63
|
/** Short suffix that keeps a store's id distinct from a same-named Worker. */
|
|
61
64
|
const ID_SUFFIX: Record<string, string> = {
|
|
@@ -63,6 +66,8 @@ const ID_SUFFIX: Record<string, string> = {
|
|
|
63
66
|
d1_database: 'd1',
|
|
64
67
|
kv_namespace: 'kv',
|
|
65
68
|
queue: 'queue',
|
|
69
|
+
container: 'container',
|
|
70
|
+
database: 'db',
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
function slug(text: string): string {
|
package/src/infra/infra.test.ts
CHANGED
|
@@ -112,6 +112,66 @@ describe('extractWranglerManifest', () => {
|
|
|
112
112
|
expect(manifest.bindings[0]).toMatchObject({ to: 'cloudflare:worker:api', binding: 'API' });
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
test('OpenBot: a Worker fronting a Container, reached through its Durable Object', () => {
|
|
116
|
+
const manifest = extractWranglerManifest(
|
|
117
|
+
`{
|
|
118
|
+
"name": "openbot",
|
|
119
|
+
"main": "src/index.ts",
|
|
120
|
+
// Postgres is external (DATABASE_URL, a secret).
|
|
121
|
+
"containers": [
|
|
122
|
+
{ "class_name": "OpenBot", "image": "../../Dockerfile", "instance_type": "standard-1", "max_instances": 1 }
|
|
123
|
+
],
|
|
124
|
+
"durable_objects": { "bindings": [{ "name": "OPENBOT", "class_name": "OpenBot" }] },
|
|
125
|
+
"vars": { "EMBEDDED_POSTGRES": "off" }
|
|
126
|
+
}`,
|
|
127
|
+
{ file: 'deploy/cloudflare/wrangler.jsonc' },
|
|
128
|
+
);
|
|
129
|
+
expect(manifest.resources.map((r) => r.key)).toEqual([
|
|
130
|
+
'cloudflare:worker:openbot',
|
|
131
|
+
'cloudflare:container:openbot-openbot',
|
|
132
|
+
]);
|
|
133
|
+
expect(manifest.resources[1]).toMatchObject({
|
|
134
|
+
label: 'OpenBot',
|
|
135
|
+
attributes: { image: '../../Dockerfile', instanceType: 'standard-1', maxInstances: '1' },
|
|
136
|
+
source: { pointer: '/containers/0' },
|
|
137
|
+
});
|
|
138
|
+
expect(manifest.bindings).toEqual([
|
|
139
|
+
{
|
|
140
|
+
from: 'cloudflare:worker:openbot',
|
|
141
|
+
to: 'cloudflare:container:openbot-openbot',
|
|
142
|
+
binding: 'OPENBOT',
|
|
143
|
+
source: {
|
|
144
|
+
tool: 'wrangler',
|
|
145
|
+
file: 'deploy/cloudflare/wrangler.jsonc',
|
|
146
|
+
pointer: '/durable_objects/bindings/0',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
// Same-named Worker and Container stay distinct containers in the sketch.
|
|
151
|
+
const { nodes, edges } = infraToC4(manifest);
|
|
152
|
+
expect(nodes.map((n) => [n.id, n.containerKind, n.technology])).toEqual([
|
|
153
|
+
['container:openbot', 'application', 'Cloudflare Worker'],
|
|
154
|
+
['container:openbot-container', 'application', 'Cloudflare Container'],
|
|
155
|
+
]);
|
|
156
|
+
expect(edges.map((e) => e.label)).toEqual(['env.OPENBOT']);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('a named container keeps its name; a Durable Object of another Worker is not its path', () => {
|
|
160
|
+
const manifest = extractWranglerManifest(
|
|
161
|
+
{
|
|
162
|
+
name: 'web',
|
|
163
|
+
containers: [{ name: 'runner', class_name: 'Runner' }],
|
|
164
|
+
durable_objects: { bindings: [{ name: 'RUNNER', class_name: 'Runner', script_name: 'other' }] },
|
|
165
|
+
},
|
|
166
|
+
{ file: 'wrangler.jsonc' },
|
|
167
|
+
);
|
|
168
|
+
expect(manifest.resources.map((r) => r.key)).toEqual([
|
|
169
|
+
'cloudflare:worker:web',
|
|
170
|
+
'cloudflare:container:runner',
|
|
171
|
+
]);
|
|
172
|
+
expect(manifest.bindings).toEqual([]);
|
|
173
|
+
});
|
|
174
|
+
|
|
115
175
|
test('a config with no Worker name declares nothing', () => {
|
|
116
176
|
expect(extractWranglerManifest('{}', { file: 'wrangler.jsonc' })).toEqual({
|
|
117
177
|
resources: [],
|
package/src/infra/wrangler.ts
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
* binding is the access path between them — named exactly as code names it
|
|
7
7
|
* (`env.TOPIC_BLOBS`), which is what makes the binding a join to trail steps.
|
|
8
8
|
*
|
|
9
|
+
* A `containers` entry is a second deployable unit: a Cloudflare Container the
|
|
10
|
+
* Worker starts and routes to through a Durable Object. The access path is the
|
|
11
|
+
* Durable Object binding of the same class, so that is the edge.
|
|
12
|
+
*
|
|
13
|
+
* Secrets are not in a wrangler config, so anything reached through one (an
|
|
14
|
+
* external Postgres behind `DATABASE_URL`, say) is not declared here and cannot
|
|
15
|
+
* be read from it.
|
|
16
|
+
*
|
|
9
17
|
* Top-level config only. Named environments (`env.staging`) are not read yet.
|
|
10
18
|
*/
|
|
11
19
|
|
|
@@ -144,5 +152,52 @@ export function extractWranglerManifest(
|
|
|
144
152
|
});
|
|
145
153
|
}
|
|
146
154
|
|
|
155
|
+
// Containers. Wrangler names the application `<worker>-<class_name>`,
|
|
156
|
+
// lowercased with spaces dashed, unless the entry names it.
|
|
157
|
+
const durableBindings = isObject(root.durable_objects) ? root.durable_objects.bindings : undefined;
|
|
158
|
+
const containers = Array.isArray(root.containers) ? root.containers : [];
|
|
159
|
+
containers.forEach((entry, index) => {
|
|
160
|
+
if (!isObject(entry)) return;
|
|
161
|
+
const className = str(entry.class_name);
|
|
162
|
+
const name =
|
|
163
|
+
str(entry.name) ??
|
|
164
|
+
(className ? `${workerName}-${className}`.toLowerCase().replace(/ /g, '-') : undefined);
|
|
165
|
+
if (!name) return;
|
|
166
|
+
const pointer = `/containers/${index}`;
|
|
167
|
+
const key = infraResourceKey(PROVIDER, 'container', name);
|
|
168
|
+
const attributes: Record<string, string> = {};
|
|
169
|
+
const image = str(entry.image);
|
|
170
|
+
if (image) attributes.image = image;
|
|
171
|
+
const instanceType = str(entry.instance_type);
|
|
172
|
+
if (instanceType) attributes.instanceType = instanceType;
|
|
173
|
+
if (typeof entry.max_instances === 'number') {
|
|
174
|
+
attributes.maxInstances = String(entry.max_instances);
|
|
175
|
+
}
|
|
176
|
+
resources.push({
|
|
177
|
+
key,
|
|
178
|
+
provider: PROVIDER,
|
|
179
|
+
resourceType: 'container',
|
|
180
|
+
name,
|
|
181
|
+
label: className ?? name,
|
|
182
|
+
source: source(pointer),
|
|
183
|
+
...(Object.keys(attributes).length > 0 ? { attributes } : {}),
|
|
184
|
+
});
|
|
185
|
+
if (!className || !Array.isArray(durableBindings)) return;
|
|
186
|
+
durableBindings.forEach((durable, durableIndex) => {
|
|
187
|
+
if (!isObject(durable) || str(durable.class_name) !== className) return;
|
|
188
|
+
// A binding with `script_name` reaches a class another Worker defines.
|
|
189
|
+
const script = str(durable.script_name);
|
|
190
|
+
if (script && script !== workerName) return;
|
|
191
|
+
const binding = str(durable.name);
|
|
192
|
+
if (!binding) return;
|
|
193
|
+
bindings.push({
|
|
194
|
+
from: workerKey,
|
|
195
|
+
to: key,
|
|
196
|
+
binding,
|
|
197
|
+
source: source(`/durable_objects/bindings/${durableIndex}`),
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
147
202
|
return { resources, bindings };
|
|
148
203
|
}
|
package/src/node.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type {
|
|
|
32
32
|
} from './storage/topic-types';
|
|
33
33
|
export { formatTopicReferenceLink, parseTopicReferenceLink } from './storage/topic-reference-links';
|
|
34
34
|
export { toSharedTopic } from './storage/topic-share';
|
|
35
|
-
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection } from './storage/topic-share';
|
|
35
|
+
export type { SharedTopic, SharedTopicAsset, SharedTopicProjection, SharedTopicReference } from './storage/topic-share';
|
|
36
36
|
|
|
37
37
|
// OpenCode event retrieval (Node.js only - SQLite)
|
|
38
38
|
export { OpenCodeEventStore, defaultOpenCodeDBPath } from './opencode/OpenCodeEventStore';
|
|
@@ -19,11 +19,31 @@ describe('toSharedTopic', () => {
|
|
|
19
19
|
expect(uploads).toEqual([]);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
test('
|
|
22
|
+
test('keeps model, sketch and topic references by id and drops drawings', () => {
|
|
23
23
|
const { topic } = toSharedTopic({
|
|
24
24
|
...base,
|
|
25
|
-
subsystemModels: [{ modelId: 'sg-1', trailIds: ['wt-a'] }],
|
|
26
|
-
references: [
|
|
25
|
+
subsystemModels: [{ modelId: 'sg-1', trailIds: ['wt-a'] }, { modelId: 'sg-2', trailIds: [] }],
|
|
26
|
+
references: [
|
|
27
|
+
{ kind: 'c4-sketch', sketchId: 'c4s-1' },
|
|
28
|
+
{ kind: 'drawing', drawingId: 'd-1' },
|
|
29
|
+
{ kind: 'topic', topicId: 'topic-2' },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
expect(topic.subsystemModels).toEqual([
|
|
33
|
+
{ modelId: 'sg-1', trailIds: ['wt-a'] },
|
|
34
|
+
{ modelId: 'sg-2' },
|
|
35
|
+
]);
|
|
36
|
+
expect(topic.references).toEqual([
|
|
37
|
+
{ kind: 'c4-sketch', sketchId: 'c4s-1' },
|
|
38
|
+
{ kind: 'topic', topicId: 'topic-2' },
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('omits empty reference lists', () => {
|
|
43
|
+
const { topic } = toSharedTopic({
|
|
44
|
+
...base,
|
|
45
|
+
subsystemModels: [],
|
|
46
|
+
references: [{ kind: 'drawing', drawingId: 'd-1' }],
|
|
27
47
|
});
|
|
28
48
|
expect(topic).not.toHaveProperty('subsystemModels');
|
|
29
49
|
expect(topic).not.toHaveProperty('references');
|
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
* Portable projection of a topic for sharing outside the machine that authored
|
|
3
3
|
* it. Browser-safe (no `node:*`).
|
|
4
4
|
*
|
|
5
|
-
* A {@link DraftTopic} carries fields that only mean something locally:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A {@link DraftTopic} carries fields that only mean something locally: inline
|
|
6
|
+
* image bytes, local asset origins and drawing references. {@link toSharedTopic}
|
|
7
|
+
* drops those and splits image bytes out so a host can upload each one
|
|
8
|
+
* separately.
|
|
9
|
+
*
|
|
10
|
+
* References to subsystem models, C4 sketches and other topics are kept as ids.
|
|
11
|
+
* A share is published under its local id, so a reader resolves the same id
|
|
12
|
+
* against the sharing service instead of the local store. A reference whose
|
|
13
|
+
* target was not shared (or not with the reader) is simply unavailable.
|
|
9
14
|
*/
|
|
10
15
|
|
|
11
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
DraftTopic,
|
|
18
|
+
TopicAsset,
|
|
19
|
+
TopicCreator,
|
|
20
|
+
TopicReference,
|
|
21
|
+
TopicSubsystemModelRef,
|
|
22
|
+
} from './topic-types';
|
|
23
|
+
|
|
24
|
+
/** A reference a shared topic can carry. Drawings have no shared form yet. */
|
|
25
|
+
export type SharedTopicReference = Exclude<TopicReference, { kind: 'drawing' }>;
|
|
12
26
|
|
|
13
27
|
/** An image a shared topic refers to. Bytes travel separately, keyed by `id`. */
|
|
14
28
|
export interface SharedTopicAsset {
|
|
@@ -23,9 +37,8 @@ export interface SharedTopicAsset {
|
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
/**
|
|
26
|
-
* A topic as it leaves the authoring machine. No
|
|
27
|
-
*
|
|
28
|
-
* against `assets`.
|
|
40
|
+
* A topic as it leaves the authoring machine. No inline bytes; `description`
|
|
41
|
+
* is unchanged, so `asset://<id>` links still resolve against `assets`.
|
|
29
42
|
*/
|
|
30
43
|
export interface SharedTopic {
|
|
31
44
|
id: string;
|
|
@@ -39,6 +52,10 @@ export interface SharedTopic {
|
|
|
39
52
|
updatedAt: string;
|
|
40
53
|
createdBy?: TopicCreator;
|
|
41
54
|
assets?: SharedTopicAsset[];
|
|
55
|
+
/** Subsystem models the topic concerns, by share id (same as the local id). */
|
|
56
|
+
subsystemModels?: TopicSubsystemModelRef[];
|
|
57
|
+
/** Attached C4 sketches and related topics, by share id. */
|
|
58
|
+
references?: SharedTopicReference[];
|
|
42
59
|
}
|
|
43
60
|
|
|
44
61
|
export interface SharedTopicProjection {
|
|
@@ -50,9 +67,9 @@ export interface SharedTopicProjection {
|
|
|
50
67
|
/**
|
|
51
68
|
* Project a local topic into its shared form.
|
|
52
69
|
*
|
|
53
|
-
* Dropped:
|
|
54
|
-
*
|
|
55
|
-
*
|
|
70
|
+
* Dropped: drawing references (no shared form), each asset's `source` (local
|
|
71
|
+
* Storybook origin) and inline `data`. Assets with neither `data` nor `url`
|
|
72
|
+
* cannot be resolved by a reader and are omitted.
|
|
56
73
|
*/
|
|
57
74
|
export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
|
|
58
75
|
const assets: SharedTopicAsset[] = [];
|
|
@@ -71,6 +88,14 @@ export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
|
|
|
71
88
|
if (asset.data) uploads.push({ id: asset.id, mime: asset.mime, data: asset.data });
|
|
72
89
|
}
|
|
73
90
|
|
|
91
|
+
const subsystemModels = (topic.subsystemModels ?? []).map((ref) => ({
|
|
92
|
+
modelId: ref.modelId,
|
|
93
|
+
...(ref.trailIds?.length ? { trailIds: [...ref.trailIds] } : {}),
|
|
94
|
+
}));
|
|
95
|
+
const references = (topic.references ?? []).filter(
|
|
96
|
+
(ref): ref is SharedTopicReference => ref.kind !== 'drawing',
|
|
97
|
+
);
|
|
98
|
+
|
|
74
99
|
return {
|
|
75
100
|
topic: {
|
|
76
101
|
id: topic.id,
|
|
@@ -81,6 +106,8 @@ export function toSharedTopic(topic: DraftTopic): SharedTopicProjection {
|
|
|
81
106
|
updatedAt: topic.updatedAt,
|
|
82
107
|
...(topic.createdBy ? { createdBy: { ...topic.createdBy } } : {}),
|
|
83
108
|
...(assets.length ? { assets } : {}),
|
|
109
|
+
...(subsystemModels.length ? { subsystemModels } : {}),
|
|
110
|
+
...(references.length ? { references: references.map((ref) => ({ ...ref })) } : {}),
|
|
84
111
|
},
|
|
85
112
|
uploads,
|
|
86
113
|
};
|