@resistdesign/voltra 3.0.0-alpha.27 → 3.0.0-alpha.28

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.
@@ -23,6 +23,20 @@ export type RouteAdapter = {
23
23
  /** Optional capability check for backward navigation. */
24
24
  canGoBack?: () => boolean;
25
25
  };
26
+ /**
27
+ * Optional runtime integration for root Route provider mode.
28
+ *
29
+ * Use this to layer platform-specific side effects (for example, native
30
+ * hardware back wiring) without coupling core app routing to a platform API.
31
+ */
32
+ export type RouteRuntimeIntegration = {
33
+ /**
34
+ * Start integration against the active adapter.
35
+ *
36
+ * Return a cleanup function when teardown is required.
37
+ */
38
+ setup: (adapter: RouteAdapter) => void | (() => void);
39
+ };
26
40
  /**
27
41
  * Supported query value types for route serialization.
28
42
  */
@@ -136,5 +150,9 @@ export type RouteProps<ParamsType extends Record<string, any>> = {
136
150
  * Optional external URL ingress for root provider mode only.
137
151
  */
138
152
  ingress?: UniversalRouteIngress;
153
+ /**
154
+ * Optional runtime integration hook for root provider mode only.
155
+ */
156
+ runtimeIntegration?: RouteRuntimeIntegration;
139
157
  };
140
158
  export declare const Route: <ParamsType extends Record<string, any>>(props: PropsWithChildren<RouteProps<ParamsType>>) => import("react/jsx-runtime").JSX.Element | null;
@@ -55,16 +55,6 @@ export type UniversalRouteIngress = {
55
55
  */
56
56
  mapURLToPath?: (url: string) => string;
57
57
  };
58
- type ReactNativeBackHandler = {
59
- addEventListener: (eventName: "hardwareBackPress", listener: () => boolean) => {
60
- remove?: () => void;
61
- } | void;
62
- removeEventListener?: (eventName: "hardwareBackPress", listener: () => boolean) => void;
63
- };
64
- /**
65
- * Safely resolve React Native BackHandler for Android runtimes only.
66
- */
67
- export declare const tryGetReactNativeBackHandler: () => ReactNativeBackHandler | undefined;
68
58
  /**
69
59
  * Detect whether browser history is available at runtime.
70
60
  */
@@ -81,4 +71,3 @@ export declare const createNativeRouteAdapter: (initialPath?: string, ingress?:
81
71
  * Create a runtime-selected RouteAdapter for web/native environments.
82
72
  */
83
73
  export declare const createUniversalAdapter: (options?: CreateUniversalAdapterOptions) => RouteAdapter;
84
- export {};
package/build/index.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { getPotentialJSONValue, getPathArray } from '../chunk-GYWRAW3Y.js';
2
+ import '../chunk-I2KLQ2HA.js';
1
3
  import { SyntaxKind, isLiteralTypeNode, isStringLiteral, isNumericLiteral, createSourceFile, ScriptTarget } from 'typescript';
2
4
 
3
- // src/build/TypeMapping.ts
4
5
  var convertASTToMap = (node, map = {}, parentName) => {
5
6
  node.forEachChild((child) => {
6
7
  const { kind: childKind } = child;
@@ -26,17 +27,6 @@ var convertASTToMap = (node, map = {}, parentName) => {
26
27
  return map;
27
28
  };
28
29
 
29
- // src/common/Routing.ts
30
- var PATH_DELIMITER = "/";
31
- var getPotentialJSONValue = (value) => {
32
- try {
33
- return JSON.parse(value);
34
- } catch (error) {
35
- return value;
36
- }
37
- };
38
- var getPathArray = (path, delimiter = PATH_DELIMITER, filterEmptyOutput = false, filterEmptyInput = true, useJson = true, uriDecodeParts = true) => path.split(delimiter).filter(filterEmptyInput ? (p) => p !== "" : () => true).map(uriDecodeParts ? decodeURIComponent : (x) => x).map(useJson ? getPotentialJSONValue : (p) => p).filter(filterEmptyOutput ? (p) => p ?? false : () => true);
39
-
40
30
  // src/common/TypeParsing/ParsingUtils/extractCommentTags.ts
41
31
  var TAG_NAME_PATH_DELIMITER = ".";
42
32
  var getFlatTagValue = (tagValue) => {
package/common/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_VALIDATORS, getValidityValue, hasValue, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern } from '../chunk-LGM75I6P.js';
2
+ export { TypeInfoORMServiceError } from '../chunk-HVY7POTD.js';
3
+ export { TypeOperation } from '../chunk-IWRHGGGH.js';
4
+ import '../chunk-GYWRAW3Y.js';
5
+ import '../chunk-I2KLQ2HA.js';
6
+
1
7
  // src/common/CommandLine/collectRequiredEnvironmentVariables.ts
2
8
  var collectRequiredEnvironmentVariables = (varNames) => {
3
9
  const result = {};
@@ -27,387 +33,4 @@ ${missingEnvVars.map((vN) => `- ${vN}`).join(`
27
33
  return result;
28
34
  };
29
35
 
30
- // src/common/TypeParsing/TypeInfo.ts
31
- var TypeOperation = /* @__PURE__ */ ((TypeOperation2) => {
32
- TypeOperation2["CREATE"] = "CREATE";
33
- TypeOperation2["READ"] = "READ";
34
- TypeOperation2["UPDATE"] = "UPDATE";
35
- TypeOperation2["DELETE"] = "DELETE";
36
- return TypeOperation2;
37
- })(TypeOperation || {});
38
-
39
- // src/common/TypeInfoORM/Types.ts
40
- var TypeInfoORMServiceError = /* @__PURE__ */ ((TypeInfoORMServiceError2) => {
41
- TypeInfoORMServiceError2["NO_DRIVERS_SUPPLIED"] = "NO_DRIVERS_SUPPLIED";
42
- TypeInfoORMServiceError2["NO_RELATIONSHIP_DRIVERS_SUPPLIED"] = "NO_RELATIONSHIP_DRIVERS_SUPPLIED";
43
- TypeInfoORMServiceError2["NO_PRIMARY_FIELD_VALUE_SUPPLIED"] = "NO_PRIMARY_FIELD_VALUE_SUPPLIED";
44
- TypeInfoORMServiceError2["INVALID_DRIVER"] = "INVALID_DRIVER";
45
- TypeInfoORMServiceError2["INVALID_RELATIONSHIP_DRIVER"] = "INVALID_RELATIONSHIP_DRIVER";
46
- TypeInfoORMServiceError2["INVALID_TYPE_INFO"] = "INVALID_TYPE_INFO";
47
- TypeInfoORMServiceError2["TYPE_INFO_MISSING_PRIMARY_FIELD"] = "TYPE_INFO_MISSING_PRIMARY_FIELD";
48
- TypeInfoORMServiceError2["INVALID_RELATIONSHIP"] = "INVALID_RELATIONSHIP";
49
- TypeInfoORMServiceError2["INVALID_OPERATION"] = "INVALID_OPERATION";
50
- TypeInfoORMServiceError2["MISSING_ACCESSING_ROLE"] = "MISSING_ACCESSING_ROLE";
51
- TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_CRITERIA"] = "INDEXING_UNSUPPORTED_CRITERIA";
52
- TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_COMBINATION"] = "INDEXING_UNSUPPORTED_COMBINATION";
53
- TypeInfoORMServiceError2["INDEXING_MISSING_INDEX_FIELD"] = "INDEXING_MISSING_INDEX_FIELD";
54
- TypeInfoORMServiceError2["INDEXING_MISSING_BACKEND"] = "INDEXING_MISSING_BACKEND";
55
- TypeInfoORMServiceError2["INDEXING_REQUIRES_CRITERIA"] = "INDEXING_REQUIRES_CRITERIA";
56
- return TypeInfoORMServiceError2;
57
- })(TypeInfoORMServiceError || {});
58
-
59
- // src/common/Routing.ts
60
- var PATH_DELIMITER = "/";
61
- var getPathString = (parts = [], delimiter = PATH_DELIMITER, filterEmptyInput = false, useJson = true, uriEncodeParts = false) => parts.filter(filterEmptyInput ? (p) => p ?? false : () => true).map(useJson ? (p) => JSON.stringify(p) : (x) => x).map(uriEncodeParts ? encodeURIComponent : (x) => x).join(delimiter);
62
-
63
- // src/common/TypeParsing/Validation.ts
64
- var RelationshipValidationType = /* @__PURE__ */ ((RelationshipValidationType2) => {
65
- RelationshipValidationType2["INCLUDE"] = "INCLUDE";
66
- RelationshipValidationType2["EXCLUDE"] = "EXCLUDE";
67
- RelationshipValidationType2["STRICT_EXCLUDE"] = "STRICT_EXCLUDE";
68
- return RelationshipValidationType2;
69
- })(RelationshipValidationType || {});
70
- var INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
71
- var PRIMITIVE_ERROR_MESSAGE_CONSTANTS = {
72
- string: "NOT_A_STRING",
73
- number: "NOT_A_NUMBER",
74
- boolean: "NOT_A_BOOLEAN"
75
- };
76
- var ERROR_MESSAGE_CONSTANTS = {
77
- MISSING: "MISSING",
78
- INVALID_OPTION: "INVALID_OPTION",
79
- INVALID_FIELD: "INVALID_FIELD",
80
- RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED",
81
- INVALID_TYPE: "INVALID_TYPE",
82
- NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED",
83
- TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST",
84
- INVALID_PATTERN: "INVALID_PATTERN",
85
- VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN"
86
- };
87
- var DENIED_TYPE_OPERATIONS = {
88
- CREATE: "DENIED_TYPE_OPERATION_CREATE",
89
- READ: "DENIED_TYPE_OPERATION_READ",
90
- UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
91
- DELETE: "DENIED_TYPE_OPERATION_DELETE"
92
- };
93
- var validateValueMatchesPattern = (typeName, value, pattern) => {
94
- const results = {
95
- typeName,
96
- valid: true,
97
- error: "",
98
- errorMap: {}
99
- };
100
- const valueSupplied = typeof value !== "undefined";
101
- const patternSupplied = typeof pattern === "string" && pattern.trim() !== "";
102
- if (!valueSupplied || !patternSupplied) {
103
- try {
104
- const regex = new RegExp(pattern);
105
- const testResult = typeof value === "string" && regex.test(value);
106
- if (!testResult) {
107
- results.valid = false;
108
- results.error = ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN;
109
- }
110
- } catch (e) {
111
- results.valid = false;
112
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN;
113
- }
114
- }
115
- return results;
116
- };
117
- var getValidityValue = (existing, pending) => !existing ? false : pending;
118
- var TYPE_KEYWORD_VALIDATORS = {
119
- string: (value) => typeof value === "string",
120
- number: (value) => typeof value === "number",
121
- boolean: (value) => typeof value === "boolean"
122
- };
123
- var hasValue = (value) => value ?? false;
124
- var validateKeywordType = (value, type) => {
125
- const validator = TYPE_KEYWORD_VALIDATORS[type];
126
- let valid = true;
127
- if (validator) {
128
- valid = validator(value);
129
- }
130
- return valid;
131
- };
132
- var validateCustomType = (value, customType, customValidators) => {
133
- let valid = true;
134
- if (customValidators && customType) {
135
- const validator = customValidators[customType];
136
- if (validator) {
137
- try {
138
- valid = validator(value);
139
- } catch (e) {
140
- valid = false;
141
- }
142
- }
143
- }
144
- return valid;
145
- };
146
- var validateTypeInfoFieldValue = (value, typeInfoField, typeInfoMap, ignoreArray = false, strict = false, customValidators, typeOperation, relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */, itemIsPartial) => {
147
- const {
148
- type,
149
- typeReference,
150
- array,
151
- optional,
152
- possibleValues,
153
- tags: { customType, constraints: { pattern = void 0 } = {} } = {}
154
- } = typeInfoField;
155
- const results = {
156
- typeName: typeReference ?? type,
157
- valid: true,
158
- error: "",
159
- errorMap: {}
160
- };
161
- const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
162
- const valueIsUndefined = typeof value === "undefined";
163
- const valueIsNull = value === null;
164
- const canSkipValidation = itemIsPartial && (valueIsUndefined || valueIsNull) || optional && valueIsUndefined;
165
- if (canSkipValidation) {
166
- results.valid = true;
167
- } else if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
168
- results.valid = false;
169
- results.error = ERROR_MESSAGE_CONSTANTS.MISSING;
170
- } else if (array && !ignoreArray) {
171
- const {
172
- valid: validArray,
173
- error: arrayError,
174
- errorMap: arrayErrorMap
175
- } = validateArrayOfTypeInfoFieldValues(
176
- value,
177
- typeInfoField,
178
- typeInfoMap,
179
- strict,
180
- customValidators,
181
- typeOperation,
182
- relationshipValidationType,
183
- itemIsPartial
184
- );
185
- results.valid = getValidityValue(results.valid, validArray);
186
- results.error = arrayError;
187
- results.errorMap = arrayErrorMap;
188
- } else {
189
- if (typeReference) {
190
- if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
191
- const {
192
- valid: validTypeInfo,
193
- error: typeInfoError,
194
- errorMap: typeInfoErrorMap
195
- } = validateTypeInfoValue(
196
- value,
197
- typeReference,
198
- typeInfoMap,
199
- strict,
200
- customValidators,
201
- typeOperation,
202
- relationshipValidationType,
203
- itemIsPartial
204
- );
205
- results.valid = getValidityValue(results.valid, validTypeInfo);
206
- results.error = typeInfoError;
207
- results.errorMap = typeInfoErrorMap;
208
- } else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
209
- const valueSupplied = typeof value !== "undefined";
210
- if (valueSupplied) {
211
- results.valid = false;
212
- results.error = ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED;
213
- }
214
- } else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
215
- results.valid = getValidityValue(results.valid, true);
216
- }
217
- } else if (possibleValues && !possibleValues.includes(value)) {
218
- results.valid = false;
219
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_OPTION;
220
- } else {
221
- const pendingValid = validateKeywordType(value, type);
222
- const customValid = validateCustomType(
223
- value,
224
- customType,
225
- customValidators
226
- );
227
- results.valid = getValidityValue(results.valid, pendingValid);
228
- results.valid = getValidityValue(results.valid, customValid);
229
- if (type === "string" && typeof pattern === "string") {
230
- const { valid: patternValid, error: patternError } = validateValueMatchesPattern(value, pattern);
231
- results.valid = getValidityValue(results.valid, patternValid);
232
- results.error = patternError;
233
- }
234
- if (!customValid) {
235
- results.error = INVALID_CUSTOM_TYPE;
236
- } else if (!results.valid) {
237
- results.error = results.error ? results.error : PRIMITIVE_ERROR_MESSAGE_CONSTANTS[type];
238
- }
239
- }
240
- }
241
- return results;
242
- };
243
- var validateArrayOfTypeInfoFieldValues = (values = [], typeInfoField, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
244
- const { type, typeReference } = typeInfoField;
245
- const results = {
246
- typeName: typeReference ?? type,
247
- valid: true,
248
- error: "",
249
- errorMap: {}
250
- };
251
- for (let i = 0; i < values.length; i++) {
252
- const v = values[i];
253
- const {
254
- valid: indexValid,
255
- error: indexError = "",
256
- errorMap: indexErrorMap
257
- } = validateTypeInfoFieldValue(
258
- v,
259
- typeInfoField,
260
- typeInfoMap,
261
- true,
262
- strict,
263
- customValidators,
264
- typeOperation,
265
- relationshipValidationType,
266
- itemIsPartial
267
- );
268
- results.valid = getValidityValue(results.valid, indexValid);
269
- results.errorMap[getPathString([i])] = [indexError];
270
- for (const er in indexErrorMap) {
271
- results.errorMap[getPathString([i, er])] = indexErrorMap[er];
272
- }
273
- }
274
- return results;
275
- };
276
- var validateTypeInfoFieldOperationAllowed = (fieldName, fieldOperation, typeInfoField) => {
277
- const results = {
278
- typeName: null,
279
- valid: true,
280
- error: "",
281
- errorMap: {}
282
- };
283
- if (fieldOperation && typeInfoField) {
284
- const {
285
- type,
286
- typeReference,
287
- tags = {}
288
- } = typeInfoField || {};
289
- const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
290
- results.typeName = typeReference ?? type;
291
- results.valid = !denied;
292
- if (!results.valid) {
293
- results.error = DENIED_TYPE_OPERATIONS[fieldOperation];
294
- results.errorMap[fieldName] = [results.error];
295
- }
296
- }
297
- return results;
298
- };
299
- var validateTypeOperationAllowed = (typeName, valueFields, typeOperation, typeInfo) => {
300
- const results = {
301
- typeName,
302
- valid: true,
303
- error: "",
304
- errorMap: {}
305
- };
306
- const { fields = {}, tags = {} } = typeInfo;
307
- const { deniedOperations: { [typeOperation]: denied = false } = {} } = tags;
308
- if (denied) {
309
- results.valid = false;
310
- results.error = DENIED_TYPE_OPERATIONS[typeOperation];
311
- } else {
312
- for (const vF of valueFields) {
313
- const vFieldInfo = fields[vF];
314
- const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
315
- results.valid = getValidityValue(results.valid, vFValid);
316
- if (!vFValid) {
317
- results.errorMap[vF] = [vFError];
318
- }
319
- }
320
- }
321
- return results;
322
- };
323
- var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
324
- const typeInfo = typeInfoMap[typeInfoFullName];
325
- const results = {
326
- typeName: typeInfoFullName,
327
- valid: !!typeInfo,
328
- error: !!typeInfo ? "" : ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST,
329
- errorMap: {}
330
- };
331
- if (typeInfo) {
332
- const { primaryField, fields, unionFieldSets } = typeInfo;
333
- if (typeOperation) {
334
- const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
335
- const {
336
- valid: operationValid,
337
- error: operationError,
338
- errorMap: operationErrorMap
339
- } = validateTypeOperationAllowed(
340
- typeInfoFullName,
341
- valueFields,
342
- typeOperation,
343
- typeInfo
344
- );
345
- results.valid = getValidityValue(results.valid, operationValid);
346
- results.error = operationError;
347
- for (const oE in operationErrorMap) {
348
- const existingError = results.errorMap[oE] ?? [];
349
- results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
350
- }
351
- if (!operationValid && operationError) {
352
- results.error = operationError;
353
- }
354
- }
355
- if (unionFieldSets) {
356
- const valueFields = Object.keys(value || {});
357
- let valid = false;
358
- for (const uFS of unionFieldSets) {
359
- valid = valueFields.every((vF) => uFS.includes(vF));
360
- if (valid) {
361
- break;
362
- }
363
- }
364
- if (!valid) {
365
- results.valid = false;
366
- results.error = ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED;
367
- }
368
- } else if (strict) {
369
- const knownFields = Object.keys(fields || {});
370
- const valueFields = Object.keys(value || {});
371
- for (const vF of valueFields) {
372
- if (!knownFields.includes(vF)) {
373
- results.valid = false;
374
- results.errorMap[vF] = [ERROR_MESSAGE_CONSTANTS.INVALID_FIELD];
375
- }
376
- }
377
- }
378
- if (fields) {
379
- for (const key in fields) {
380
- if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
381
- const typeInfoField = fields[key];
382
- const fieldValue = value[key];
383
- const {
384
- valid: fieldValid,
385
- error: fieldError,
386
- errorMap: fieldErrorMap
387
- } = validateTypeInfoFieldValue(
388
- fieldValue,
389
- typeInfoField,
390
- typeInfoMap,
391
- false,
392
- strict,
393
- customValidators,
394
- typeOperation,
395
- relationshipValidationType,
396
- itemIsPartial
397
- );
398
- results.valid = getValidityValue(results.valid, fieldValid);
399
- results.errorMap[key] = [fieldError];
400
- for (const fE in fieldErrorMap) {
401
- results.errorMap[getPathString([key, fE])] = fieldErrorMap[fE];
402
- }
403
- }
404
- }
405
- }
406
- if (!results.valid && !results.error) {
407
- results.error = ERROR_MESSAGE_CONSTANTS.INVALID_TYPE;
408
- }
409
- }
410
- return results;
411
- };
412
-
413
- export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_VALIDATORS, TypeInfoORMServiceError, TypeOperation, collectRequiredEnvironmentVariables, getValidityValue, hasValue, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern };
36
+ export { collectRequiredEnvironmentVariables };