@globaltypesystem/gts-ts 0.1.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/.eslintrc.json +16 -0
- package/.github/workflows/ci.yml +198 -0
- package/.gitmodules +3 -0
- package/.prettierrc +7 -0
- package/LICENSE +201 -0
- package/Makefile +64 -0
- package/README.md +298 -0
- package/dist/cast.d.ts +9 -0
- package/dist/cast.d.ts.map +1 -0
- package/dist/cast.js +153 -0
- package/dist/cast.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +318 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/compatibility.d.ts +11 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +176 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/extract.d.ts +13 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +194 -0
- package/dist/extract.js.map +1 -0
- package/dist/gts.d.ts +18 -0
- package/dist/gts.d.ts.map +1 -0
- package/dist/gts.js +472 -0
- package/dist/gts.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/query.d.ts +10 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +171 -0
- package/dist/query.js.map +1 -0
- package/dist/relationships.d.ts +7 -0
- package/dist/relationships.d.ts.map +1 -0
- package/dist/relationships.js +80 -0
- package/dist/relationships.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +132 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/server.d.ts +33 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +678 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/types.d.ts +61 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +3 -0
- package/dist/server/types.js.map +1 -0
- package/dist/store.d.ts +39 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +1026 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/dist/x-gts-ref.d.ts +35 -0
- package/dist/x-gts-ref.d.ts.map +1 -0
- package/dist/x-gts-ref.js +304 -0
- package/dist/x-gts-ref.js.map +1 -0
- package/jest.config.js +13 -0
- package/package.json +54 -0
- package/src/cast.ts +179 -0
- package/src/cli/index.ts +315 -0
- package/src/compatibility.ts +201 -0
- package/src/extract.ts +213 -0
- package/src/gts.ts +550 -0
- package/src/index.ts +97 -0
- package/src/query.ts +191 -0
- package/src/relationships.ts +91 -0
- package/src/server/index.ts +112 -0
- package/src/server/server.ts +771 -0
- package/src/server/types.ts +74 -0
- package/src/store.ts +1178 -0
- package/src/types.ts +138 -0
- package/src/x-gts-ref.ts +349 -0
- package/tests/gts.test.ts +525 -0
- package/tsconfig.json +32 -0
package/dist/extract.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GtsExtractor = void 0;
|
|
4
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const gts_1 = require("./gts");
|
|
7
|
+
function getDefaultConfig() {
|
|
8
|
+
return {
|
|
9
|
+
entityIdFields: ['$id', '$$id', 'gtsId', 'gtsIid', 'gtsOid', 'gtsI', 'gts_id', 'gts_oid', 'gts_iid', 'id'],
|
|
10
|
+
schemaIdFields: [
|
|
11
|
+
'$schema',
|
|
12
|
+
'$$schema',
|
|
13
|
+
'gtsTid',
|
|
14
|
+
'gtsType',
|
|
15
|
+
'gtsT',
|
|
16
|
+
'gts_t',
|
|
17
|
+
'gts_tid',
|
|
18
|
+
'gts_type',
|
|
19
|
+
'type',
|
|
20
|
+
'schema',
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
class GtsExtractor {
|
|
25
|
+
static normalizeValue(value, fieldName) {
|
|
26
|
+
let normalized = value.trim();
|
|
27
|
+
// Strip the "gts://" URI prefix for $id field (JSON Schema compatibility)
|
|
28
|
+
if (fieldName === '$id' && normalized.startsWith(types_1.GTS_URI_PREFIX)) {
|
|
29
|
+
normalized = normalized.substring(types_1.GTS_URI_PREFIX.length);
|
|
30
|
+
}
|
|
31
|
+
else if (normalized.startsWith(types_1.GTS_URI_PREFIX)) {
|
|
32
|
+
normalized = normalized.substring(types_1.GTS_URI_PREFIX.length);
|
|
33
|
+
}
|
|
34
|
+
return normalized;
|
|
35
|
+
}
|
|
36
|
+
static findFirstValidField(content, fields, requireValid = false) {
|
|
37
|
+
if (typeof content !== 'object' || content === null) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// Look for any field with a value
|
|
41
|
+
for (const field of fields) {
|
|
42
|
+
if (field in content && typeof content[field] === 'string') {
|
|
43
|
+
const value = this.normalizeValue(content[field], field);
|
|
44
|
+
if (value) {
|
|
45
|
+
// If requireValid is true, only return valid GTS IDs
|
|
46
|
+
if (requireValid) {
|
|
47
|
+
if (gts_1.Gts.isValidGtsID(value)) {
|
|
48
|
+
return { field, value };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Return any non-empty value
|
|
53
|
+
return { field, value };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
static isJsonSchema(content) {
|
|
61
|
+
if (typeof content !== 'object' || content === null) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// Check for JSON Schema meta-schema
|
|
65
|
+
// Issue #25: A document is a schema ONLY if $schema field is present
|
|
66
|
+
const schemaField = content['$schema'] || content['$$schema'];
|
|
67
|
+
if (typeof schemaField === 'string') {
|
|
68
|
+
// Standard JSON Schema meta-schema URLs
|
|
69
|
+
if (schemaField.includes('json-schema.org')) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
// GTS schema reference (ends with ~)
|
|
73
|
+
if (schemaField.startsWith(types_1.GTS_URI_PREFIX) || schemaField.startsWith(types_1.GTS_PREFIX)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
static extractID(content, schemaContent) {
|
|
80
|
+
const config = getDefaultConfig();
|
|
81
|
+
let id = '';
|
|
82
|
+
let schemaId = null;
|
|
83
|
+
let selectedEntityField;
|
|
84
|
+
let selectedSchemaIdField;
|
|
85
|
+
const isSchema = this.isJsonSchema(content);
|
|
86
|
+
if (typeof content === 'object' && content !== null) {
|
|
87
|
+
// Extract entity ID (look for any non-empty value, preferring valid GTS IDs)
|
|
88
|
+
const entityResult = this.findFirstValidField(content, config.entityIdFields);
|
|
89
|
+
if (entityResult) {
|
|
90
|
+
id = entityResult.value;
|
|
91
|
+
selectedEntityField = entityResult.field;
|
|
92
|
+
}
|
|
93
|
+
// Check if entity ID is a valid GTS ID
|
|
94
|
+
const isValidGtsId = id && gts_1.Gts.isValidGtsID(id);
|
|
95
|
+
// An ID has a "chain" if there's a ~ somewhere in the middle (not just at the end)
|
|
96
|
+
// e.g., "gts.a.b.c.d.v1~x.y.z.w.v2" or "gts.a.b.c.d.v1~x.y.z.w.v2~" both have chains
|
|
97
|
+
// but "gts.a.b.c.d.v1~" does NOT have a chain (it's a base type)
|
|
98
|
+
const hasChain = isValidGtsId &&
|
|
99
|
+
(() => {
|
|
100
|
+
// Find first ~
|
|
101
|
+
const firstTilde = id.indexOf('~');
|
|
102
|
+
if (firstTilde === -1)
|
|
103
|
+
return false;
|
|
104
|
+
// Check if there's anything meaningful after the first ~
|
|
105
|
+
const afterTilde = id.substring(firstTilde + 1);
|
|
106
|
+
// If ends with ~, remove it for chain check
|
|
107
|
+
const checkPart = afterTilde.endsWith('~') ? afterTilde.slice(0, -1) : afterTilde;
|
|
108
|
+
return checkPart.length > 0;
|
|
109
|
+
})();
|
|
110
|
+
if (isSchema) {
|
|
111
|
+
// For schemas: extract schema_id based on rules
|
|
112
|
+
// Rule: For base schemas, schema_id is the $schema field value
|
|
113
|
+
// Rule: For derived schemas (chained $id), schema_id is the parent type from the chain
|
|
114
|
+
if (hasChain && id.endsWith('~')) {
|
|
115
|
+
// Derived schema - extract parent type from chain
|
|
116
|
+
// e.g., "gts.x.core.events.type.v1~x.commerce.orders.order_placed.v1.0~"
|
|
117
|
+
// -> schema_id = "gts.x.core.events.type.v1~"
|
|
118
|
+
const withoutTrailingTilde = id.slice(0, -1);
|
|
119
|
+
const lastTilde = withoutTrailingTilde.lastIndexOf('~');
|
|
120
|
+
if (lastTilde > 0) {
|
|
121
|
+
schemaId = id.substring(0, lastTilde + 1);
|
|
122
|
+
selectedSchemaIdField = selectedEntityField;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (hasChain && !id.endsWith('~')) {
|
|
126
|
+
// Chained instance ID in schema (shouldn't happen, but handle it)
|
|
127
|
+
const lastTilde = id.lastIndexOf('~');
|
|
128
|
+
if (lastTilde > 0) {
|
|
129
|
+
schemaId = id.substring(0, lastTilde + 1);
|
|
130
|
+
selectedSchemaIdField = selectedEntityField;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Base schema (single segment type or no $id) - use $schema field value
|
|
135
|
+
const schemaResult = this.findFirstValidField(content, ['$schema', '$$schema']);
|
|
136
|
+
if (schemaResult) {
|
|
137
|
+
schemaId = schemaResult.value;
|
|
138
|
+
selectedSchemaIdField = schemaResult.field;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// For instances (non-schemas):
|
|
144
|
+
// $id without $schema means the doc is an instance, NOT a schema
|
|
145
|
+
// Even if $id ends with ~, without $schema it's not treated as a schema
|
|
146
|
+
// So we should NOT derive schema_id from $id alone
|
|
147
|
+
// Skip $id for non-schemas - $id without $schema should not be used for schema_id
|
|
148
|
+
const isIdFromDollarId = selectedEntityField === '$id' || selectedEntityField === '$$id';
|
|
149
|
+
if (hasChain && !isIdFromDollarId) {
|
|
150
|
+
// Extract schema ID from chain (only if not from $id)
|
|
151
|
+
const lastTilde = id.lastIndexOf('~');
|
|
152
|
+
if (lastTilde > 0 && !id.endsWith('~')) {
|
|
153
|
+
schemaId = id.substring(0, lastTilde + 1);
|
|
154
|
+
selectedSchemaIdField = selectedEntityField;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (schemaId === null && !isIdFromDollarId) {
|
|
158
|
+
// No chain or chain didn't provide schema_id - try explicit schema fields
|
|
159
|
+
// But don't use schema_id_fields that are $id variants (they were already checked above)
|
|
160
|
+
const explicitSchemaFields = config.schemaIdFields.filter((f) => f !== '$id' && f !== '$$id');
|
|
161
|
+
const schemaResult = this.findFirstValidField(content, explicitSchemaFields, true);
|
|
162
|
+
if (schemaResult) {
|
|
163
|
+
schemaId = schemaResult.value;
|
|
164
|
+
selectedSchemaIdField = schemaResult.field;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// If schema_id is still null, check regular chained ID (including from $id)
|
|
168
|
+
if (schemaId === null && hasChain && !id.endsWith('~')) {
|
|
169
|
+
const lastTilde = id.lastIndexOf('~');
|
|
170
|
+
if (lastTilde > 0) {
|
|
171
|
+
schemaId = id.substring(0, lastTilde + 1);
|
|
172
|
+
selectedSchemaIdField = selectedEntityField;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Try to extract from schemaContent if provided and schemaId is still null
|
|
178
|
+
if (schemaId === null && schemaContent && typeof schemaContent === 'object') {
|
|
179
|
+
const schemaEntityResult = this.findFirstValidField(schemaContent, config.entityIdFields);
|
|
180
|
+
if (schemaEntityResult) {
|
|
181
|
+
schemaId = schemaEntityResult.value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
id,
|
|
186
|
+
schema_id: schemaId,
|
|
187
|
+
selected_entity_field: selectedEntityField,
|
|
188
|
+
selected_schema_id_field: selectedSchemaIdField,
|
|
189
|
+
is_schema: isSchema,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.GtsExtractor = GtsExtractor;
|
|
194
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":";;;AAQA,4CAgBC;AAxBD,mCAAoE;AACpE,+BAA4B;AAO5B,SAAgB,gBAAgB;IAC9B,OAAO;QACL,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC;QAC1G,cAAc,EAAE;YACd,SAAS;YACT,UAAU;YACV,QAAQ;YACR,SAAS;YACT,MAAM;YACN,OAAO;YACP,SAAS;YACT,UAAU;YACV,MAAM;YACN,QAAQ;SACT;KACF,CAAC;AACJ,CAAC;AAED,MAAa,YAAY;IACf,MAAM,CAAC,cAAc,CAAC,KAAa,EAAE,SAAkB;QAC7D,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAE9B,0EAA0E;QAC1E,IAAI,SAAS,KAAK,KAAK,IAAI,UAAU,CAAC,UAAU,CAAC,sBAAc,CAAC,EAAE,CAAC;YACjE,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,sBAAc,CAAC,MAAM,CAAC,CAAC;QAC3D,CAAC;aAAM,IAAI,UAAU,CAAC,UAAU,CAAC,sBAAc,CAAC,EAAE,CAAC;YACjD,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,sBAAc,C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CAAC;wBACjB,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC;wBAC9B,qBAAqB,GAAG,YAAY,CAAC,KAAK,CAAC;oBAC7C,CAAC;gBACH,CAAC;gBAED,4EAA4E;gBAC5E,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;oBACvD,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;oBACtC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;wBAClB,QAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;wBAC1C,qBAAqB,GAAG,mBAAmB,CAAC;oBAC9C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,2EAA2E;QAC3E,IAAI,QAAQ,KAAK,IAAI,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YAC5E,MAAM,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;YAC1F,IAAI,kBAAkB,EAAE,CAAC;gBACvB,QAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAC;YACtC,CAAC;QACH,CAAC;QAED,OAAO;YACL,EAAE;YACF,SAAS,EAAE,QAAQ;YACnB,qBAAqB,EAAE,mBAAmB;YAC1C,wBAAwB,EAAE,qBAAqB;YAC/C,SAAS,EAAE,QAAQ;SACpB,CAAC;IACJ,CAAC;CACF;AA1LD,oCA0LC"}
|
package/dist/gts.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GtsID, ValidationResult, ParseResult, MatchResult, UUIDResult } from './types';
|
|
2
|
+
export declare class Gts {
|
|
3
|
+
static parseGtsID(id: string): GtsID;
|
|
4
|
+
private static splitPreservingTilde;
|
|
5
|
+
private static parseSegment;
|
|
6
|
+
static isValidGtsID(id: string): boolean;
|
|
7
|
+
static validateGtsID(id: string): ValidationResult;
|
|
8
|
+
static parseID(id: string): ParseResult;
|
|
9
|
+
static isType(id: string): boolean;
|
|
10
|
+
static toUUID(id: string): string;
|
|
11
|
+
static idToUUID(id: string): UUIDResult;
|
|
12
|
+
static matchIDPattern(candidate: string, pattern: string): MatchResult;
|
|
13
|
+
private static validateWildcard;
|
|
14
|
+
private static parseGtsIDInternal;
|
|
15
|
+
private static wildcardMatch;
|
|
16
|
+
private static matchSegments;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=gts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gts.d.ts","sourceRoot":"","sources":["../src/gts.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,EAIL,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,UAAU,EACX,MAAM,SAAS,CAAC;AAMjB,qBAAa,GAAG;IACd,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK;IAQpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC,OAAO,CAAC,MAAM,CAAC,YAAY;IAuJ3B,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAYxC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB;IA2BlD,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW;IAgBvC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIlC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIjC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAgBvC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW;IAoDtE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAiD/B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAwEjC,OAAO,CAAC,MAAM,CAAC,aAAa;IAmB5B,OAAO,CAAC,MAAM,CAAC,aAAa;CA8E7B"}
|