@convert-buddy/importer-contracts 0.1.0-beta.1 → 0.1.0-beta.3

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/LICENSE CHANGED
@@ -1,10 +1,10 @@
1
- Convert Buddy Free Distribution License 1.0
1
+ Diakrio Free Distribution License 1.0
2
2
 
3
- Copyright (c) Convert Buddy copyright holders. All rights reserved, except as
3
+ Copyright (c) Diakrio copyright holders. All rights reserved, except as
4
4
  expressly granted below or by an applicable separate license.
5
5
 
6
6
  1. Scope
7
- This license applies to first-party material in official Convert Buddy package
7
+ This license applies to first-party material in official Diakrio package
8
8
  distributions carrying this license (the Software), to the extent its copyright
9
9
  holders have authority to license that material on these terms. It does not grant
10
10
  access to the private development repository or license undistributed source code.
@@ -26,12 +26,12 @@ archiving, including private registries and public package caches.
26
26
  Keep this license and all applicable copyright and third-party notices with
27
27
  redistributed copies, or in an accompanying, accessible legal-notices file or page
28
28
  when bundling prevents retaining individual files. Identify your modifications
29
- without implying that the modified distribution is an official Convert Buddy release.
29
+ without implying that the modified distribution is an official Diakrio release.
30
30
 
31
31
  3. Reserved rights
32
32
  This is a proprietary distribution license, not an open-source license. Except
33
33
  as allowed above, you may not distribute or sublicense the Software as a standalone
34
- library, engine, or replacement Convert Buddy package, or rebrand or sell it as
34
+ library, engine, or replacement Diakrio package, or rebrand or sell it as
35
35
  your own standalone software product. This does not restrict selling your own
36
36
  applications or services that integrate the Software as permitted in section 2.
37
37
  No rights to unpublished source code, trademarks, or an endorsement are granted.
@@ -39,14 +39,14 @@ Rights not expressly granted are reserved. Statutory rights that cannot lawfully
39
39
  be excluded or limited by agreement remain unaffected.
40
40
 
41
41
  4. Hosted services
42
- This license does not include Convert Buddy Cloud subscriptions, hosted quotas,
42
+ This license does not include Diakrio Cloud subscriptions, hosted quotas,
43
43
  support commitments, or service-level guarantees. Those services have separate
44
44
  terms. Their availability or pricing does not change the free-use grant for a
45
45
  copy of the Software obtained under this license.
46
46
 
47
47
  5. Earlier releases and third-party material
48
48
  This license does not revoke, replace, or restrict rights already granted under
49
- MIT or any other separate license. Earlier Convert Buddy releases and portions
49
+ MIT or any other separate license. Earlier Diakrio or Convert Buddy releases and portions
50
50
  made available under MIT retain those permissions; see NOTICE and accompanying
51
51
  license files. Where that material is included in this distribution, its separate
52
52
  license continues to apply to that material. Third-party libraries, models,
package/NOTICE CHANGED
@@ -1,13 +1,13 @@
1
- Convert Buddy distribution notices
1
+ Diakrio distribution notices
2
2
 
3
- Earlier Convert Buddy releases and portions licensed under MIT retain their
3
+ Earlier Diakrio and Convert Buddy releases and portions licensed under MIT retain their
4
4
  original permissions. The free distribution license does not revoke those rights.
5
5
  The following is the original repository license text, preserved for that material.
6
6
  It is not a grant of MIT rights for new proprietary material.
7
7
 
8
8
  MIT License
9
9
 
10
- Copyright (c) Convert Buddy contributors
10
+ Copyright (c) Diakrio contributors
11
11
 
12
12
  Permission is hereby granted, free of charge, to any person obtaining a copy
13
13
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,74 +1,9 @@
1
- # `@convert-buddy/importer-contracts`
1
+ # @convert-buddy/importer-contracts
2
2
 
3
- Public, versioned data contracts shared by the free importer and Convert
4
- Buddy Cloud. The package contains plain TypeScript types plus strict runtime
5
- parsers; persisted configuration is JSON and is not tied to a validation
6
- framework.
3
+ > **Convert Buddy is now Diakrio.** This package remains available as a compatibility alias. New projects should install [@diakrio/importer-contracts](https://www.npmjs.com/package/@diakrio%2Fimporter-contracts).
7
4
 
8
- ## Contracts
5
+ ## Migration
9
6
 
10
- - `TargetSchemaV1` describes an immutable published target schema.
11
- - `SourceProfileV1` describes a bounded, privacy-reviewed view of an input file.
12
- - `TransformPlanV1` describes allowlisted deterministic mapping operations.
13
- - `AcceptedRecordBatchV1` and `DeliveryReceiptV1` define the no-store delivery
14
- envelope and acknowledgement.
7
+ Replace `@convert-buddy/importer-contracts` with `@diakrio/importer-contracts` in your dependencies and imports. The compatibility package forwards the existing public entry points, but new features and documentation use the Diakrio name.
15
8
 
16
- Every parser rejects unknown properties, oversized payloads, non-JSON values,
17
- prototype-polluting property names, incompatible operations, and invalid
18
- cross-contract references. `parseTransformPlanV1` requires the exact source
19
- profile and target schema version that were used for the mapping request.
20
-
21
- ```ts
22
- import {
23
- parseSourceProfileV1,
24
- parseTargetSchemaV1,
25
- parseTransformPlanV1,
26
- } from "@convert-buddy/importer-contracts";
27
-
28
- const schema = parseTargetSchemaV1(schemaJson);
29
- const profile = parseSourceProfileV1(profileJson);
30
- const plan = parseTransformPlanV1(modelOutput, {
31
- sourceProfile: profile,
32
- targetSchema: schema,
33
- targetSchemaVersionId: "schema-version-17",
34
- });
35
- ```
36
-
37
- Sample values are rejected by default. A caller must explicitly pass
38
- `{ allowSamples: true }`, and the configured count and string-length limits are
39
- still applied.
40
-
41
- AI output is always data. This package deliberately has no operation for code,
42
- general expressions, network access, or dynamic evaluation.
43
-
44
- ## Delivery verification
45
-
46
- Customer endpoints should verify the exact raw request bytes before parsing the
47
- JSON body. The helper checks HMAC-SHA-256 authenticity and the default five-minute
48
- freshness window:
49
-
50
- ```ts
51
- import {
52
- DELIVERY_HEADERS,
53
- verifyDeliverySignatureV1,
54
- } from "@convert-buddy/importer-contracts";
55
-
56
- const rawBody = new Uint8Array(await request.arrayBuffer());
57
- const verified = await verifyDeliverySignatureV1({
58
- batchId: request.headers.get(DELIVERY_HEADERS.batchId) ?? "",
59
- importId: request.headers.get(DELIVERY_HEADERS.importId) ?? "",
60
- rawBody,
61
- signature: request.headers.get(DELIVERY_HEADERS.signature) ?? "",
62
- signingSecret: env.CONVERT_BUDDY_SIGNING_SECRET,
63
- timestamp: request.headers.get(DELIVERY_HEADERS.signatureTimestamp) ?? "",
64
- });
65
- ```
66
-
67
- Make `batchId` idempotent before applying records. Do not reconstruct or
68
- re-serialize the body for signature verification.
69
-
70
- ## Distribution and license
71
-
72
- Free for personal and commercial application use under the [Convert Buddy Free
73
- Distribution License](LICENSE). Application bundling is allowed with notices
74
- retained. Development source is private; Cloud services have separate terms.
9
+ Documentation: https://diakrio.com/docs
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts';
package/package.json CHANGED
@@ -1,49 +1,51 @@
1
1
  {
2
2
  "name": "@convert-buddy/importer-contracts",
3
- "version": "0.1.0-beta.1",
4
- "description": "Versioned public contracts for Convert Buddy importer schemas, profiles, transform plans, and delivery",
3
+ "version": "0.1.0-beta.3",
4
+ "description": "Compatibility package: @convert-buddy/importer-contracts has moved to @diakrio/importer-contracts.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
7
+ "sideEffects": false,
9
8
  "exports": {
10
9
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/index.js"
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
+ },
13
+ "./typescript-source": {
14
+ "types": "./typescript-source.d.ts",
15
+ "default": "./typescript-source.js"
16
+ },
17
+ "./zod-source": {
18
+ "types": "./zod-source.d.ts",
19
+ "default": "./zod-source.js"
13
20
  }
14
21
  },
15
22
  "files": [
16
- "dist/**",
23
+ "index.js",
24
+ "index.d.ts",
25
+ "typescript-source.js",
26
+ "typescript-source.d.ts",
27
+ "zod-source.js",
28
+ "zod-source.d.ts",
17
29
  "README.md",
18
30
  "LICENSE",
19
- "NOTICE",
20
- "!**/*.map"
31
+ "NOTICE"
21
32
  ],
22
- "sideEffects": false,
23
- "scripts": {
24
- "build": "tsup",
25
- "check": "tsc --noEmit",
26
- "test": "npm run build && tsc -p tsconfig.test.json && node --test .test-dist/tests/*.test.js",
27
- "prepack": "npm run check && npm test && node ../../scripts/distribution-policy.mjs package",
28
- "prepublishOnly": "node ../../scripts/distribution-policy.mjs package"
29
- },
30
- "devDependencies": {
31
- "@types/node": "^25.0.3",
32
- "tsup": "^8.5.1",
33
- "typescript": "^5.5.0"
33
+ "dependencies": {
34
+ "@diakrio/importer-contracts": "0.1.0-beta.3"
34
35
  },
35
36
  "engines": {
36
37
  "node": ">=20.17"
37
38
  },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/brunohanss/convert-buddy.git",
41
- "directory": "packages/importer-contracts"
42
- },
43
39
  "publishConfig": {
44
40
  "access": "public",
45
41
  "registry": "https://registry.npmjs.org/",
46
- "provenance": false
42
+ "provenance": false,
43
+ "tag": "beta"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/brunohanss/diakrio.git",
48
+ "directory": "packages/legacy/importer-contracts"
47
49
  },
48
- "homepage": "https://convert-buddy.app/docs"
50
+ "homepage": "https://diakrio.com/docs/migrating-from-convert-buddy"
49
51
  }
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts/typescript-source';
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts/typescript-source';
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts/zod-source';
package/zod-source.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@diakrio/importer-contracts/zod-source';
package/dist/index.d.ts DELETED
@@ -1,234 +0,0 @@
1
- type JsonPrimitive = null | boolean | number | string;
2
- type JsonValue = JsonPrimitive | JsonValue[] | {
3
- [key: string]: JsonValue;
4
- };
5
- declare const TARGET_FIELD_TYPES: readonly ["string", "integer", "number", "boolean", "date", "datetime", "enum"];
6
- type TargetFieldType = (typeof TARGET_FIELD_TYPES)[number];
7
- type UnknownFieldPolicyV1 = "ignore" | "reject" | "preserve";
8
- interface TargetConstraintsV1 {
9
- min?: number;
10
- max?: number;
11
- minLength?: number;
12
- maxLength?: number;
13
- pattern?: string;
14
- values?: string[];
15
- }
16
- interface TargetFieldV1 {
17
- key: string;
18
- label: string;
19
- type: TargetFieldType;
20
- required?: boolean;
21
- aliases?: string[];
22
- description?: string;
23
- defaultValue?: JsonValue;
24
- constraints?: TargetConstraintsV1;
25
- }
26
- interface TargetSchemaV1 {
27
- version: 1;
28
- id: string;
29
- name: string;
30
- fields: TargetFieldV1[];
31
- unknownFields: UnknownFieldPolicyV1;
32
- }
33
- declare const SOURCE_FORMATS: readonly ["csv", "xml", "json", "ndjson", "xlsx"];
34
- type SourceFormatV1 = (typeof SOURCE_FORMATS)[number];
35
- declare const SOURCE_INFERRED_TYPES: readonly ["string", "integer", "number", "boolean", "date", "datetime", "enum", "null", "object", "array", "unknown"];
36
- type SourceInferredTypeV1 = (typeof SOURCE_INFERRED_TYPES)[number];
37
- interface SourceInferredTypeRatioV1 {
38
- type: SourceInferredTypeV1;
39
- ratio: number;
40
- }
41
- interface SourceFieldProfileV1 {
42
- path: string;
43
- normalizedName: string;
44
- inferredTypes: SourceInferredTypeRatioV1[];
45
- nullRatio: number;
46
- distinctEstimate?: number;
47
- samples?: string[];
48
- }
49
- interface SourceProfileV1 {
50
- version: 1;
51
- format: SourceFormatV1;
52
- structureFingerprint: string;
53
- recordPath?: string;
54
- fields: SourceFieldProfileV1[];
55
- }
56
- type TransformOperationV1 = {
57
- op: "trim";
58
- } | {
59
- op: "lowercase";
60
- } | {
61
- op: "uppercase";
62
- } | {
63
- op: "coerce";
64
- type: Exclude<TargetFieldType, "enum">;
65
- } | {
66
- op: "parse_date";
67
- formats: string[];
68
- } | {
69
- op: "replace";
70
- pattern: string;
71
- replacement: string;
72
- } | {
73
- op: "enum_map";
74
- values: Record<string, string>;
75
- } | {
76
- op: "split";
77
- separator: string;
78
- index: number;
79
- } | {
80
- op: "join";
81
- separator: string;
82
- } | {
83
- op: "default";
84
- value: JsonValue;
85
- };
86
- interface TransformMappingV1 {
87
- sources: string[];
88
- target: string;
89
- confidence: number;
90
- reasonCode: string;
91
- operations: TransformOperationV1[];
92
- }
93
- interface TransformWarningV1 {
94
- code: string;
95
- message: string;
96
- }
97
- interface TransformPlanV1 {
98
- version: 1;
99
- sourceFingerprint: string;
100
- targetSchemaVersionId: string;
101
- mappings: TransformMappingV1[];
102
- unmappedSources: string[];
103
- unsatisfiedTargets: string[];
104
- warnings: TransformWarningV1[];
105
- }
106
- interface AcceptedRecordBatchV1 {
107
- version: 1;
108
- records: Array<Record<string, JsonValue>>;
109
- }
110
- interface DeliveryReceiptV1 {
111
- version: 1;
112
- batchId: string;
113
- recordCount: number;
114
- status: "delivered" | "duplicate";
115
- }
116
- type ContractIssueCode = "invalid_type" | "invalid_value" | "missing_value" | "unknown_property" | "duplicate_value" | "limit_exceeded" | "unsafe_pattern" | "incompatible_operation" | "unknown_source" | "unknown_target" | "fingerprint_mismatch" | "schema_version_mismatch";
117
- interface ContractIssue {
118
- code: ContractIssueCode;
119
- path: string;
120
- message: string;
121
- }
122
-
123
- declare function canonicalStringify(value: unknown): string;
124
- declare function canonicalByteLength(value: unknown): number;
125
- declare function cloneJsonValue(value: JsonValue): JsonValue;
126
-
127
- /** Calendar dates are never interpreted in the browser's local timezone. */
128
- declare function isCalendarDate(value: string): boolean;
129
- /** Datetimes require an explicit UTC offset; ambiguous local times are rejected. */
130
- declare function isOffsetDateTime(value: string): boolean;
131
- /** Explicit numeric calendar formats; conflicting interpretations remain invalid. */
132
- declare function parseCalendarFormats(value: string, formats: readonly string[]): string | undefined;
133
-
134
- interface ContractLimits {
135
- maxAliasesPerField: number;
136
- maxCanonicalBytes: number;
137
- maxDescriptionLength: number;
138
- maxDictionaryEntries: number;
139
- maxFields: number;
140
- maxMappings: number;
141
- maxOperationsPerMapping: number;
142
- maxPatternLength: number;
143
- maxRecordPathLength: number;
144
- maxSamplesPerField: number;
145
- maxSampleLength: number;
146
- maxStringLength: number;
147
- maxWarnings: number;
148
- }
149
- declare const DEFAULT_CONTRACT_LIMITS: Readonly<ContractLimits>;
150
- interface ContractParseOptions {
151
- allowSamples?: boolean;
152
- limits?: Partial<ContractLimits>;
153
- }
154
- declare function resolveContractLimits(overrides: Partial<ContractLimits> | undefined): Readonly<ContractLimits>;
155
-
156
- declare const DELIVERY_PROTOCOL_VERSION: 1;
157
- declare const DEFAULT_MAX_DELIVERY_BATCH_BYTES: number;
158
- declare const DEFAULT_MAX_DELIVERY_BATCH_RECORDS = 10000;
159
- declare const DEFAULT_DELIVERY_SIGNATURE_TOLERANCE_SECONDS: number;
160
- declare const DELIVERY_HEADERS: Readonly<{
161
- readonly apiKey: "x-convert-buddy-key";
162
- readonly batchId: "x-convert-buddy-batch-id";
163
- readonly destination: "x-convert-buddy-destination";
164
- readonly importId: "x-convert-buddy-import-id";
165
- readonly signature: "x-convert-buddy-signature";
166
- readonly signatureTimestamp: "x-convert-buddy-signature-timestamp";
167
- }>;
168
- interface DeliveryBatchParseOptions extends ContractParseOptions {
169
- maxBatchBytes?: number;
170
- maxRecords?: number;
171
- }
172
- interface DeliverySignatureInputV1 {
173
- batchId: string;
174
- importId: string;
175
- rawBody: Uint8Array;
176
- timestamp: string;
177
- }
178
- interface DeliverySignatureVerificationV1 extends DeliverySignatureInputV1 {
179
- nowEpochSeconds?: number;
180
- signature: string;
181
- signingSecret: string | Uint8Array;
182
- toleranceSeconds?: number;
183
- }
184
- declare function parseAcceptedRecordBatchV1(input: unknown, options?: DeliveryBatchParseOptions): AcceptedRecordBatchV1;
185
- declare function signDeliveryRequestV1(signingSecret: string | Uint8Array, input: DeliverySignatureInputV1): Promise<string>;
186
- declare function verifyDeliverySignatureV1(input: DeliverySignatureVerificationV1): Promise<boolean>;
187
-
188
- interface StructureDescriptorV1 {
189
- version: 1;
190
- format: SourceProfileV1["format"];
191
- recordPath?: string;
192
- fields: Array<{
193
- path: string;
194
- normalizedName: string;
195
- inferredTypes: string[];
196
- }>;
197
- }
198
- declare function describeSourceStructure(profile: SourceProfileV1): StructureDescriptorV1;
199
- declare function computeStructureFingerprint(profile: SourceProfileV1): Promise<string>;
200
-
201
- declare function parseSourceProfileV1(input: unknown, options?: ContractParseOptions): SourceProfileV1;
202
-
203
- declare function parseTargetSchemaV1(input: unknown, options?: ContractParseOptions): TargetSchemaV1;
204
- declare function isTargetValueCompatible(value: JsonValue, type: TargetFieldType): boolean;
205
-
206
- interface TargetSchemaBuilderOptionsV1 {
207
- id: string;
208
- name: string;
209
- unknownFields?: UnknownFieldPolicyV1;
210
- }
211
- /** Creates validated, immutable schema manifests without coupling consumers to a validator library. */
212
- declare class TargetSchemaBuilderV1 {
213
- #private;
214
- private readonly options;
215
- constructor(options: Readonly<TargetSchemaBuilderOptionsV1>);
216
- field(field: Readonly<TargetFieldV1>): this;
217
- fields(fields: ReadonlyArray<Readonly<TargetFieldV1>>): this;
218
- build(): Readonly<TargetSchemaV1>;
219
- }
220
- declare function defineTargetSchemaV1(schema: Readonly<TargetSchemaV1>): Readonly<TargetSchemaV1>;
221
-
222
- interface TransformPlanContextV1 {
223
- sourceProfile: SourceProfileV1;
224
- targetSchema: TargetSchemaV1;
225
- targetSchemaVersionId: string;
226
- }
227
- declare function parseTransformPlanV1(input: unknown, planContext: TransformPlanContextV1, options?: ContractParseOptions): TransformPlanV1;
228
-
229
- declare class ContractValidationError extends TypeError {
230
- readonly issues: readonly ContractIssue[];
231
- constructor(contractName: string, issues: readonly ContractIssue[]);
232
- }
233
-
234
- export { type AcceptedRecordBatchV1, type ContractIssue, type ContractIssueCode, type ContractLimits, type ContractParseOptions, ContractValidationError, DEFAULT_CONTRACT_LIMITS, DEFAULT_DELIVERY_SIGNATURE_TOLERANCE_SECONDS, DEFAULT_MAX_DELIVERY_BATCH_BYTES, DEFAULT_MAX_DELIVERY_BATCH_RECORDS, DELIVERY_HEADERS, DELIVERY_PROTOCOL_VERSION, type DeliveryBatchParseOptions, type DeliveryReceiptV1, type DeliverySignatureInputV1, type DeliverySignatureVerificationV1, type JsonPrimitive, type JsonValue, SOURCE_FORMATS, SOURCE_INFERRED_TYPES, type SourceFieldProfileV1, type SourceFormatV1, type SourceInferredTypeRatioV1, type SourceInferredTypeV1, type SourceProfileV1, TARGET_FIELD_TYPES, type TargetConstraintsV1, type TargetFieldType, type TargetFieldV1, type TargetSchemaBuilderOptionsV1, TargetSchemaBuilderV1, type TargetSchemaV1, type TransformMappingV1, type TransformOperationV1, type TransformPlanContextV1, type TransformPlanV1, type TransformWarningV1, type UnknownFieldPolicyV1, canonicalByteLength, canonicalStringify, cloneJsonValue, computeStructureFingerprint, defineTargetSchemaV1, describeSourceStructure, isCalendarDate, isOffsetDateTime, isTargetValueCompatible, parseAcceptedRecordBatchV1, parseCalendarFormats, parseSourceProfileV1, parseTargetSchemaV1, parseTransformPlanV1, resolveContractLimits, signDeliveryRequestV1, verifyDeliverySignatureV1 };