@knapsack/adapter-core 4.92.2--canary.eb7e898.0 → 4.92.2--canary.77d16bf.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/dist/entity-filename.d.ts +30 -0
- package/dist/entity-filename.d.ts.map +1 -0
- package/dist/entity-filename.js +42 -0
- package/dist/entity-filename.js.map +1 -0
- package/dist/entity-frontmatter.d.ts +25 -0
- package/dist/entity-frontmatter.d.ts.map +1 -0
- package/dist/entity-frontmatter.js +25 -0
- package/dist/entity-frontmatter.js.map +1 -0
- package/dist/entity-hash.d.ts +6 -0
- package/dist/entity-hash.d.ts.map +1 -0
- package/dist/entity-hash.js +12 -0
- package/dist/entity-hash.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +85 -43
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -6
- package/tsconfig.json +1 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source tagging — the single identity for a source on disk.
|
|
3
|
+
*
|
|
4
|
+
* A sourceTag is `{sourceEvt}-{hash}` — used as both the folder name
|
|
5
|
+
* and the filename tag for PCIF entities. Readable (you know the source type)
|
|
6
|
+
* and unique (hash of sourceKey).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* sourceTag('KNAPSACK', { sourceKey: 'accutech@latest' })
|
|
10
|
+
* // → 'knapsack-6d33514'
|
|
11
|
+
*
|
|
12
|
+
* // Same tag everywhere:
|
|
13
|
+
* // sources/knapsack-6d33514/ ← folder
|
|
14
|
+
* // sources/knapsack-6d33514/component/button.vue.knapsack-6d33514.mdx ← filename
|
|
15
|
+
* */
|
|
16
|
+
import { type SourceType } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Compute the source tag — the readable, filesystem-safe, deterministic
|
|
19
|
+
* identity of a source. Used as folder name and filename tag.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sourceTag(source: {
|
|
22
|
+
readonly sourceType: SourceType;
|
|
23
|
+
readonly sourceKey: string;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* Tag a bare filename for entity-stage naming.
|
|
27
|
+
* Inserts the sourceTag before the file extension.
|
|
28
|
+
*/
|
|
29
|
+
export declare function tagFilenameForEntity(filename: string, tag: ReturnType<typeof sourceTag>): string;
|
|
30
|
+
//# sourceMappingURL=entity-filename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-filename.d.ts","sourceRoot":"","sources":["../src/entity-filename.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;KAcK;AAGL,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAChC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GAAG,MAAM,CAOT;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,GAChC,MAAM,CAMR"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source tagging — the single identity for a source on disk.
|
|
3
|
+
*
|
|
4
|
+
* A sourceTag is `{sourceEvt}-{hash}` — used as both the folder name
|
|
5
|
+
* and the filename tag for PCIF entities. Readable (you know the source type)
|
|
6
|
+
* and unique (hash of sourceKey).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* sourceTag('KNAPSACK', { sourceKey: 'accutech@latest' })
|
|
10
|
+
* // → 'knapsack-6d33514'
|
|
11
|
+
*
|
|
12
|
+
* // Same tag everywhere:
|
|
13
|
+
* // sources/knapsack-6d33514/ ← folder
|
|
14
|
+
* // sources/knapsack-6d33514/component/button.vue.knapsack-6d33514.mdx ← filename
|
|
15
|
+
* */
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
17
|
+
import { SOURCE_TYPE_TO_EVT } from './types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Compute the source tag — the readable, filesystem-safe, deterministic
|
|
20
|
+
* identity of a source. Used as folder name and filename tag.
|
|
21
|
+
*/
|
|
22
|
+
export function sourceTag(source) {
|
|
23
|
+
const evt = SOURCE_TYPE_TO_EVT[source.sourceType];
|
|
24
|
+
const hash = createHash('sha256')
|
|
25
|
+
.update(source.sourceKey)
|
|
26
|
+
.digest('hex')
|
|
27
|
+
.slice(0, 7);
|
|
28
|
+
return `${evt}-${hash}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Tag a bare filename for entity-stage naming.
|
|
32
|
+
* Inserts the sourceTag before the file extension.
|
|
33
|
+
*/
|
|
34
|
+
export function tagFilenameForEntity(filename, tag) {
|
|
35
|
+
const lastDot = filename.lastIndexOf('.');
|
|
36
|
+
if (lastDot === -1)
|
|
37
|
+
return `${filename}.${tag}`;
|
|
38
|
+
const base = filename.slice(0, lastDot);
|
|
39
|
+
const ext = filename.slice(lastDot + 1);
|
|
40
|
+
return `${base}.${tag}.${ext}`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=entity-filename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-filename.js","sourceRoot":"","sources":["../src/entity-filename.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;KAcK;AAEL,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAmB,MAAM,YAAY,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,MAGzB;IACC,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;SAC9B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;SACxB,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACf,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,GAAiC;IAEjC,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,OAAO,KAAK,CAAC,CAAC;QAAE,OAAO,GAAG,QAAQ,IAAI,GAAG,EAAE,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;IACxC,OAAO,GAAG,IAAI,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type BaseEntityFrontmatter = {
|
|
2
|
+
key: string;
|
|
3
|
+
sourceKey: string;
|
|
4
|
+
source: string;
|
|
5
|
+
lastIngested: string;
|
|
6
|
+
contentHash: string;
|
|
7
|
+
extraFields?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export type ComponentEntityFrontmatter = BaseEntityFrontmatter & {
|
|
10
|
+
entityKind: 'COMPONENT';
|
|
11
|
+
platform: string;
|
|
12
|
+
import?: string | string[];
|
|
13
|
+
};
|
|
14
|
+
export type DocumentEntityFrontmatter = BaseEntityFrontmatter & {
|
|
15
|
+
entityKind: 'DOCUMENT';
|
|
16
|
+
platform?: string;
|
|
17
|
+
};
|
|
18
|
+
export type EntityFrontmatter = ComponentEntityFrontmatter | DocumentEntityFrontmatter;
|
|
19
|
+
/**
|
|
20
|
+
* Shared PCIF frontmatter serializer for MDX entities at the sources/entities stages.
|
|
21
|
+
* Keeps common provenance consistent while still allowing component/document fields.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildEntityFrontmatter(frontmatter: EntityFrontmatter): string;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=entity-frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-frontmatter.d.ts","sourceRoot":"","sources":["../src/entity-frontmatter.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,GAAG;IAC/D,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG;IAC9D,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,0BAA0B,GAC1B,yBAAyB,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAuB7E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { stringify as stringifyYaml } from 'yaml';
|
|
2
|
+
/**
|
|
3
|
+
* Shared PCIF frontmatter serializer for MDX entities at the sources/entities stages.
|
|
4
|
+
* Keeps common provenance consistent while still allowing component/document fields.
|
|
5
|
+
*/
|
|
6
|
+
export function buildEntityFrontmatter(frontmatter) {
|
|
7
|
+
const fields = {
|
|
8
|
+
key: frontmatter.key,
|
|
9
|
+
sourceKey: frontmatter.sourceKey,
|
|
10
|
+
source: frontmatter.source,
|
|
11
|
+
};
|
|
12
|
+
if (frontmatter.platform) {
|
|
13
|
+
fields.platform = frontmatter.platform;
|
|
14
|
+
}
|
|
15
|
+
if (frontmatter.entityKind === 'COMPONENT' && frontmatter.import) {
|
|
16
|
+
fields.import = frontmatter.import;
|
|
17
|
+
}
|
|
18
|
+
if (frontmatter.extraFields) {
|
|
19
|
+
Object.assign(fields, frontmatter.extraFields);
|
|
20
|
+
}
|
|
21
|
+
fields.lastIngested = frontmatter.lastIngested;
|
|
22
|
+
fields.contentHash = frontmatter.contentHash;
|
|
23
|
+
return `---\n${stringifyYaml(fields, { lineWidth: 0 }).trimEnd()}\n---`;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=entity-frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-frontmatter.js","sourceRoot":"","sources":["../src/entity-frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AA0BlD;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAA8B;IACnE,MAAM,MAAM,GAA4B;QACtC,GAAG,EAAE,WAAW,CAAC,GAAG;QACpB,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,MAAM,EAAE,WAAW,CAAC,MAAM;KAC3B,CAAC;IAEF,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;IACzC,CAAC;IAED,IAAI,WAAW,CAAC,UAAU,KAAK,WAAW,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACjE,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC;IAC/C,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC;IAE7C,OAAO,QAAQ,aAAa,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute a content hash for MDX entity bodies (first 12 hex chars of SHA-256).
|
|
3
|
+
* Used in frontmatter to track entity content changes across ingests.
|
|
4
|
+
*/
|
|
5
|
+
export declare function contentHash(content: string): string;
|
|
6
|
+
//# sourceMappingURL=entity-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-hash.d.ts","sourceRoot":"","sources":["../src/entity-hash.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a content hash for MDX entity bodies (first 12 hex chars of SHA-256).
|
|
4
|
+
* Used in frontmatter to track entity content changes across ingests.
|
|
5
|
+
*/
|
|
6
|
+
export function contentHash(content) {
|
|
7
|
+
return createHash('sha256')
|
|
8
|
+
.update(content, 'utf-8')
|
|
9
|
+
.digest('hex')
|
|
10
|
+
.slice(0, 12);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=entity-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-hash.js","sourceRoot":"","sources":["../src/entity-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;SACxB,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
* Core types, interfaces, and utilities for PCIF ingestion.
|
|
5
5
|
* All ingestion pipelines depend on this package for shared infrastructure.
|
|
6
6
|
*/
|
|
7
|
-
export type { SourceType, EntityKind, IngestSourceType, ContextEntity, Manifest, ManifestItem, ValidationResult, PipelineStage, StageInfo, MdxConfig, StorybookConfig, KnapsackConfig, FigmaConfig, ParserConfig, AdapterMessage, } from './types.js';
|
|
7
|
+
export type { SourceType, EntityKind, IngestSourceType, ContextEntity, Manifest, ManifestItem, ValidationResult, PipelineStage, StageStatus, StageInfo, MdxConfig, StorybookConfig, KnapsackConfig, FigmaConfig, ParserConfig, ChannelConfig, AdapterMessage, } from './types.js';
|
|
8
8
|
export { SOURCE_TYPE_TO_EVT } from './types.js';
|
|
9
9
|
export type { Validator, Parser, Transformer, Analyzer, ContextSrcAdapter, } from './interface.js';
|
|
10
10
|
export type { RuntimeDeps } from './runtime-deps.js';
|
|
11
11
|
export type { Logger, IngestEvt, LogContext } from './log.js';
|
|
12
12
|
export { buildLogContext } from './log.js';
|
|
13
13
|
export { writeFile } from './fs.js';
|
|
14
|
+
export { sourceTag, tagFilenameForEntity } from './entity-filename.js';
|
|
15
|
+
export { contentHash } from './entity-hash.js';
|
|
16
|
+
export type { ComponentEntityFrontmatter, DocumentEntityFrontmatter, EntityFrontmatter, } from './entity-frontmatter.js';
|
|
17
|
+
export { buildEntityFrontmatter } from './entity-frontmatter.js';
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAEV,UAAU,EACV,UAAU,EACV,gBAAgB,EAEhB,aAAa,EAEb,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAEhB,aAAa,EACb,SAAS,EAET,SAAS,EACT,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EAEZ,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD,YAAY,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAEV,UAAU,EACV,UAAU,EACV,gBAAgB,EAEhB,aAAa,EAEb,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAEhB,aAAa,EACb,WAAW,EACX,SAAS,EAET,SAAS,EACT,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EAEZ,aAAa,EAEb,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGhD,YAAY,EACV,SAAS,EACT,MAAM,EACN,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,9 @@ export { SOURCE_TYPE_TO_EVT } from './types.js';
|
|
|
8
8
|
export { buildLogContext } from './log.js';
|
|
9
9
|
// Filesystem utilities
|
|
10
10
|
export { writeFile } from './fs.js';
|
|
11
|
+
// Entity filename utilities (PCIF entities/ stage naming)
|
|
12
|
+
export { sourceTag, tagFilenameForEntity } from './entity-filename.js';
|
|
13
|
+
// Entity content hashing
|
|
14
|
+
export { contentHash } from './entity-hash.js';
|
|
15
|
+
export { buildEntityFrontmatter } from './entity-frontmatter.js';
|
|
11
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6BH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgBhD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,uBAAuB;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,0DAA0D;AAC1D,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEvE,yBAAyB;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -37,23 +37,44 @@ export interface ContextEntity {
|
|
|
37
37
|
sourceKey: string;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Pipeline stages — the ordered lifecycle stages an adapter runs through
|
|
40
|
+
* Pipeline stages — the ordered lifecycle stages an adapter runs through.
|
|
41
|
+
*
|
|
42
|
+
* Source operator (slurp): validate → parse → transform
|
|
43
|
+
* Distro operator (distro): mount → detect → build
|
|
41
44
|
*/
|
|
42
|
-
export type PipelineStage = 'parse' | 'transform' | '
|
|
45
|
+
export type PipelineStage = 'validate' | 'parse' | 'transform' | 'mount' | 'detect' | 'build';
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
47
|
+
* Stage result status — follows dbt/OTel conventions.
|
|
48
|
+
*
|
|
49
|
+
* - success: completed normally, produced expected output
|
|
50
|
+
* - failure: completed but result is bad (data problem, retry won't help)
|
|
51
|
+
* - error: didn't complete (infra/code problem, retry may help)
|
|
52
|
+
* - skipped: didn't run (precondition not met, intentionally bypassed)
|
|
53
|
+
*/
|
|
54
|
+
export type StageStatus = 'success' | 'failure' | 'error' | 'skipped';
|
|
55
|
+
/**
|
|
56
|
+
* Metadata recorded when a stage completes.
|
|
57
|
+
*
|
|
58
|
+
* Modeled after dbt run_results.json per-node shape:
|
|
59
|
+
* every stage produces a uniform result with status, timing, and counts.
|
|
45
60
|
*/
|
|
46
61
|
export interface StageInfo {
|
|
62
|
+
/** Outcome of this stage */
|
|
63
|
+
status: StageStatus;
|
|
47
64
|
/** Number of items processed in this stage */
|
|
48
65
|
itemCount: number;
|
|
49
66
|
/** Number of errors in this stage */
|
|
50
67
|
errors: number;
|
|
51
68
|
/** Duration of this stage in milliseconds */
|
|
52
69
|
durationMs: number;
|
|
70
|
+
/** ISO-8601 timestamp when this stage started */
|
|
71
|
+
startedAt: string;
|
|
53
72
|
/** ISO-8601 timestamp when this stage completed */
|
|
54
73
|
completedAt: string;
|
|
55
|
-
/** Number of items discovered
|
|
74
|
+
/** Number of items discovered (parse stage: total before filtering) */
|
|
56
75
|
discoveredItemCount?: number;
|
|
76
|
+
/** Human-readable message (error detail, skip reason, summary) */
|
|
77
|
+
message?: string;
|
|
57
78
|
}
|
|
58
79
|
/**
|
|
59
80
|
* A single item in the manifest
|
|
@@ -142,17 +163,25 @@ export interface StorybookConfig {
|
|
|
142
163
|
limit?: number;
|
|
143
164
|
}
|
|
144
165
|
/**
|
|
145
|
-
*
|
|
166
|
+
* Knapsack adapter configuration
|
|
167
|
+
*
|
|
168
|
+
* The adapter reads a pre-staged appClientData.json from Storage.
|
|
169
|
+
* Auth is handled by the GraphQL API before the adapter runs —
|
|
170
|
+
* the adapter never authenticates.
|
|
171
|
+
*
|
|
172
|
+
* @see libs/ingest-pipeline/adapters/knapsack/docs/SPEC.md
|
|
146
173
|
*/
|
|
147
174
|
export interface KnapsackConfig {
|
|
148
|
-
/**
|
|
175
|
+
/** Derived sourceKey (e.g. 'toby@latest'). Set by controller via adapter.sourceKey(). */
|
|
149
176
|
sourceKey: string;
|
|
150
|
-
/**
|
|
177
|
+
/** Site identifier — always scoped to a single Knapsack site */
|
|
178
|
+
siteId: string;
|
|
179
|
+
/** Branch name ('latest' for production, or branch name for drafts) */
|
|
151
180
|
branchName: string;
|
|
152
|
-
/**
|
|
181
|
+
/** Path to pre-staged appClientData.json in Storage */
|
|
153
182
|
inputPath: string;
|
|
154
|
-
/**
|
|
155
|
-
|
|
183
|
+
/** Commit SHA of the staged blob (short hex, e.g. 'bcf262f'). Provenance metadata — not part of sourceKey. */
|
|
184
|
+
contentHash?: string;
|
|
156
185
|
}
|
|
157
186
|
/**
|
|
158
187
|
* TBD: Figma parser configuration
|
|
@@ -180,48 +209,61 @@ export type ParserConfig = ({
|
|
|
180
209
|
type: 'figma';
|
|
181
210
|
} & FigmaConfig);
|
|
182
211
|
/**
|
|
183
|
-
*
|
|
212
|
+
* Configuration for the distro operator (mount + detect + build).
|
|
213
|
+
* channelKey is derived from channel.name in DB — url-safe, durable.
|
|
214
|
+
*/
|
|
215
|
+
export interface ChannelConfig {
|
|
216
|
+
/** Channel key — url-safe slug, folder name, durable id */
|
|
217
|
+
readonly channelKey: string;
|
|
218
|
+
/** Site identifier */
|
|
219
|
+
readonly siteId: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Structured messages emitted by operators and the controller.
|
|
184
223
|
* The handler wires these to SQS, webhooks, or direct callbacks.
|
|
185
|
-
*
|
|
186
|
-
*
|
|
224
|
+
*
|
|
225
|
+
* Universal event model inspired by dbt run_results and OTel CICD conventions:
|
|
226
|
+
* - stage.started: stage announces scope of work
|
|
227
|
+
* - item.ok: per-item success with domain-specific metadata
|
|
228
|
+
* - item.error: per-item failure
|
|
229
|
+
* - item.skip: per-item intentional bypass
|
|
230
|
+
* - stage.complete: stage finished with aggregate StageInfo + status
|
|
187
231
|
*/
|
|
188
232
|
export type AdapterMessage = {
|
|
189
|
-
stage:
|
|
190
|
-
type: '
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
type: 'item.extracted';
|
|
196
|
-
ref: string;
|
|
197
|
-
} | {
|
|
198
|
-
stage: 'parse';
|
|
199
|
-
type: 'item.failed';
|
|
200
|
-
ref: string;
|
|
201
|
-
error: string;
|
|
233
|
+
stage: PipelineStage;
|
|
234
|
+
type: 'stage.started';
|
|
235
|
+
/** Source identity — set by source stages (parse, transform) */
|
|
236
|
+
sourceKey?: string;
|
|
237
|
+
/** Channel identity — set by distro stages (mount, detect, build) */
|
|
238
|
+
channelKey?: string;
|
|
202
239
|
} | {
|
|
203
|
-
stage:
|
|
204
|
-
type: '
|
|
205
|
-
|
|
206
|
-
|
|
240
|
+
stage: PipelineStage;
|
|
241
|
+
type: 'stage.complete';
|
|
242
|
+
stageInfo: StageInfo;
|
|
243
|
+
/** Source identity — set by source stages (parse, transform) */
|
|
244
|
+
sourceKey?: string;
|
|
245
|
+
/** Channel identity — set by distro stages (mount, detect, build) */
|
|
246
|
+
channelKey?: string;
|
|
207
247
|
} | {
|
|
208
|
-
stage:
|
|
209
|
-
type: 'item.
|
|
248
|
+
stage: PipelineStage;
|
|
249
|
+
type: 'item.ok';
|
|
250
|
+
/** Item identity — ref for source stages, canonical key for distro stages */
|
|
210
251
|
ref: string;
|
|
252
|
+
/** Domain-specific metadata (entityCounts, conflictCount, files, etc.) */
|
|
253
|
+
metadata?: Record<string, unknown>;
|
|
211
254
|
} | {
|
|
212
|
-
stage:
|
|
213
|
-
type: 'item.
|
|
255
|
+
stage: PipelineStage;
|
|
256
|
+
type: 'item.error';
|
|
214
257
|
ref: string;
|
|
215
258
|
error: string;
|
|
259
|
+
/** Domain-specific context about the failure */
|
|
260
|
+
metadata?: Record<string, unknown>;
|
|
216
261
|
} | {
|
|
217
|
-
stage:
|
|
218
|
-
type: '
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
type: 'stage.complete';
|
|
224
|
-
stageInfo: StageInfo;
|
|
225
|
-
sourceKey: string;
|
|
262
|
+
stage: PipelineStage;
|
|
263
|
+
type: 'item.skip';
|
|
264
|
+
ref: string;
|
|
265
|
+
reason: string;
|
|
266
|
+
/** Domain-specific context about what was skipped */
|
|
267
|
+
metadata?: Record<string, unknown>;
|
|
226
268
|
};
|
|
227
269
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,k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AAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,GACD;IACE,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knapsack/adapter-core",
|
|
3
3
|
"description": "Core types, interfaces, and logging for ContextSrcAdapters",
|
|
4
|
-
"version": "4.92.2--canary.
|
|
4
|
+
"version": "4.92.2--canary.77d16bf.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
},
|
|
23
23
|
"author": "Knapsack (https://www.knapsack.cloud)",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@knapsack/logger": "4.92.2--canary.
|
|
25
|
+
"@knapsack/logger": "4.92.2--canary.77d16bf.0",
|
|
26
|
+
"yaml": "^2.7.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@knapsack/eslint-config-starter": "4.92.2--canary.
|
|
29
|
-
"@knapsack/typescript-config-starter": "4.92.2--canary.
|
|
29
|
+
"@knapsack/eslint-config-starter": "4.92.2--canary.77d16bf.0",
|
|
30
|
+
"@knapsack/typescript-config-starter": "4.92.2--canary.77d16bf.0",
|
|
30
31
|
"@types/node": "^22.19.11",
|
|
31
32
|
"eslint": "^9.20.0",
|
|
32
|
-
"typescript": "^
|
|
33
|
+
"typescript": "^5.9.3"
|
|
33
34
|
},
|
|
34
35
|
"license": "GPL-2.0-or-later",
|
|
35
36
|
"publishConfig": {
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"directory": "libs/ingest-pipeline/adapters/core",
|
|
41
42
|
"type": "git"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "77d16bf68c911461c261b5247b563a73e9c1eae6"
|
|
44
45
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"types": ["node"],
|
|
4
3
|
"target": "ES2022",
|
|
5
4
|
"module": "NodeNext",
|
|
6
5
|
"moduleResolution": "NodeNext",
|
|
@@ -16,5 +15,5 @@
|
|
|
16
15
|
"sourceMap": true
|
|
17
16
|
},
|
|
18
17
|
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
18
|
+
"exclude": ["node_modules", "dist", "src/**/*.test.ts"]
|
|
20
19
|
}
|