@asaidimu/anansi 2.1.0 → 3.0.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/index.d.cts +18 -60
- package/index.d.ts +18 -60
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -416,9 +416,6 @@ interface IndexDefinition {
|
|
|
416
416
|
* Nested schemas are stored in the `nestedSchemas` map of a `SchemaDefinition` and referenced by their `id`.
|
|
417
417
|
* They facilitate schema reusability, modularity, and the definition of polymorphic structures.
|
|
418
418
|
*
|
|
419
|
-
* @template T - The TypeScript type this schema represents. When `literal` is `true`, this `T`
|
|
420
|
-
* corresponds to the actual primitive type (e.g., `string`, `number`).
|
|
421
|
-
* When `literal` is `false`, `T` is typically an object type.
|
|
422
419
|
*/
|
|
423
420
|
type NestedSchemaDefinition<T> = {
|
|
424
421
|
/**
|
|
@@ -432,51 +429,27 @@ type NestedSchemaDefinition<T> = {
|
|
|
432
429
|
* This is crucial for documentation and understanding the schema's intent.
|
|
433
430
|
*/
|
|
434
431
|
description?: string;
|
|
435
|
-
} & /**
|
|
436
|
-
* Defines a literal nested schema.
|
|
437
|
-
* When `literal` is `true`, this `NestedSchemaDefinition` represents a direct primitive value
|
|
438
|
-
* rather than an object with fields.
|
|
439
|
-
* This is particularly useful for:
|
|
440
|
-
* - Defining reusable primitive types with specific constraints (e.g., a regex for an "EmailAddress" string).
|
|
441
|
-
* - Enabling direct unions between primitive types and object types within a `FieldDefinition`
|
|
442
|
-
* (e.g., `FieldType: "union"`, where one `FieldSchema` references a literal type).
|
|
443
|
-
*/ ({
|
|
444
|
-
literal: true;
|
|
445
432
|
/**
|
|
446
|
-
*
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
/** For type 'enum', specifies the allowed values. */
|
|
450
|
-
values?: Array<string | number>;
|
|
451
|
-
/**
|
|
452
|
-
* An optional default value for this literal schema.
|
|
453
|
-
* If provided, the type of `default` must strictly match the `type` specified.
|
|
454
|
-
* @example "default@example.com" for type "string"
|
|
455
|
-
* @example 0 for type "number"
|
|
456
|
-
*/
|
|
457
|
-
default?: T;
|
|
458
|
-
/**
|
|
459
|
-
* Optional constraints for additional validation rules specific to this literal type.
|
|
460
|
-
* These constraints apply directly to the primitive value.
|
|
433
|
+
* Defines database indexes for the fields within this nested schema.
|
|
434
|
+
* This is primarily applicable when `concrete` is `true`, indicating that the schema
|
|
435
|
+
* maps directly to a persistent data store table. Indexes help optimize data retrieval.
|
|
461
436
|
*/
|
|
462
|
-
|
|
437
|
+
indexes?: IndexDefinition[];
|
|
463
438
|
/**
|
|
464
|
-
* Optional generic metadata associated with the
|
|
465
|
-
* This can store any additional information relevant to tooling
|
|
466
|
-
*
|
|
439
|
+
* Optional generic metadata associated with the structured schema.
|
|
440
|
+
* This can store any additional information relevant to tooling, UI generation,
|
|
441
|
+
* or specific domain requirements that are not covered by other properties.
|
|
442
|
+
* @example `{ graphqlType: "Address", apiEndpoint: "/api/addresses" }`
|
|
467
443
|
*/
|
|
468
444
|
metadata?: Record<string, any>;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Defines a structured nested schema that represents an object with defined fields.
|
|
472
|
-
* This is the traditional way of defining complex data structures within the schema.
|
|
473
|
-
*/
|
|
474
|
-
| {
|
|
445
|
+
} & ({
|
|
475
446
|
/**
|
|
476
|
-
*
|
|
477
|
-
*
|
|
447
|
+
* Optional constraints for additional validation rules that apply to the entire structured schema.
|
|
448
|
+
* These constraints provide an extra layer of data integrity beyond basic type checking.
|
|
449
|
+
* They are less strictly necessary when using discriminated field sets (`fields` as an array),
|
|
450
|
+
* as much of the variant logic can be enforced structurally through the `when` clauses.
|
|
478
451
|
*/
|
|
479
|
-
|
|
452
|
+
constraints?: SchemaConstraint<any>;
|
|
480
453
|
/**
|
|
481
454
|
* Indicates whether this schema represents a standalone entity (`true`) or is embedded (`false`).
|
|
482
455
|
* - When `true` (`concrete: true`), the schema is treated as a distinct, fixed-structure entity,
|
|
@@ -521,27 +494,12 @@ type NestedSchemaDefinition<T> = {
|
|
|
521
494
|
value: any;
|
|
522
495
|
};
|
|
523
496
|
}>;
|
|
497
|
+
} | (Pick<FieldDefinition<T>, "name" | "default" | "schema" | "itemsType" | "constraints"> & {
|
|
524
498
|
/**
|
|
525
|
-
*
|
|
526
|
-
* These constraints provide an extra layer of data integrity beyond basic type checking.
|
|
527
|
-
* They are less strictly necessary when using discriminated field sets (`fields` as an array),
|
|
528
|
-
* as much of the variant logic can be enforced structurally through the `when` clauses.
|
|
529
|
-
*/
|
|
530
|
-
constraints?: SchemaConstraint<any>;
|
|
531
|
-
/**
|
|
532
|
-
* Defines database indexes for the fields within this nested schema.
|
|
533
|
-
* This is primarily applicable when `concrete` is `true`, indicating that the schema
|
|
534
|
-
* maps directly to a persistent data store table. Indexes help optimize data retrieval.
|
|
535
|
-
*/
|
|
536
|
-
indexes?: IndexDefinition[];
|
|
537
|
-
/**
|
|
538
|
-
* Optional generic metadata associated with the structured schema.
|
|
539
|
-
* This can store any additional information relevant to tooling, UI generation,
|
|
540
|
-
* or specific domain requirements that are not covered by other properties.
|
|
541
|
-
* @example `{ graphqlType: "Address", apiEndpoint: "/api/addresses" }`
|
|
499
|
+
* The basic primitive type that this literal schema represents.
|
|
542
500
|
*/
|
|
543
|
-
|
|
544
|
-
});
|
|
501
|
+
type: "string" | "number" | "boolean" | "array" | "set" | "enum" | "record";
|
|
502
|
+
}));
|
|
545
503
|
/**
|
|
546
504
|
* Defines a complete schema, intended as an atomic unit within a larger domain model.
|
|
547
505
|
*
|
package/index.d.ts
CHANGED
|
@@ -416,9 +416,6 @@ interface IndexDefinition {
|
|
|
416
416
|
* Nested schemas are stored in the `nestedSchemas` map of a `SchemaDefinition` and referenced by their `id`.
|
|
417
417
|
* They facilitate schema reusability, modularity, and the definition of polymorphic structures.
|
|
418
418
|
*
|
|
419
|
-
* @template T - The TypeScript type this schema represents. When `literal` is `true`, this `T`
|
|
420
|
-
* corresponds to the actual primitive type (e.g., `string`, `number`).
|
|
421
|
-
* When `literal` is `false`, `T` is typically an object type.
|
|
422
419
|
*/
|
|
423
420
|
type NestedSchemaDefinition<T> = {
|
|
424
421
|
/**
|
|
@@ -432,51 +429,27 @@ type NestedSchemaDefinition<T> = {
|
|
|
432
429
|
* This is crucial for documentation and understanding the schema's intent.
|
|
433
430
|
*/
|
|
434
431
|
description?: string;
|
|
435
|
-
} & /**
|
|
436
|
-
* Defines a literal nested schema.
|
|
437
|
-
* When `literal` is `true`, this `NestedSchemaDefinition` represents a direct primitive value
|
|
438
|
-
* rather than an object with fields.
|
|
439
|
-
* This is particularly useful for:
|
|
440
|
-
* - Defining reusable primitive types with specific constraints (e.g., a regex for an "EmailAddress" string).
|
|
441
|
-
* - Enabling direct unions between primitive types and object types within a `FieldDefinition`
|
|
442
|
-
* (e.g., `FieldType: "union"`, where one `FieldSchema` references a literal type).
|
|
443
|
-
*/ ({
|
|
444
|
-
literal: true;
|
|
445
432
|
/**
|
|
446
|
-
*
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
/** For type 'enum', specifies the allowed values. */
|
|
450
|
-
values?: Array<string | number>;
|
|
451
|
-
/**
|
|
452
|
-
* An optional default value for this literal schema.
|
|
453
|
-
* If provided, the type of `default` must strictly match the `type` specified.
|
|
454
|
-
* @example "default@example.com" for type "string"
|
|
455
|
-
* @example 0 for type "number"
|
|
456
|
-
*/
|
|
457
|
-
default?: T;
|
|
458
|
-
/**
|
|
459
|
-
* Optional constraints for additional validation rules specific to this literal type.
|
|
460
|
-
* These constraints apply directly to the primitive value.
|
|
433
|
+
* Defines database indexes for the fields within this nested schema.
|
|
434
|
+
* This is primarily applicable when `concrete` is `true`, indicating that the schema
|
|
435
|
+
* maps directly to a persistent data store table. Indexes help optimize data retrieval.
|
|
461
436
|
*/
|
|
462
|
-
|
|
437
|
+
indexes?: IndexDefinition[];
|
|
463
438
|
/**
|
|
464
|
-
* Optional generic metadata associated with the
|
|
465
|
-
* This can store any additional information relevant to tooling
|
|
466
|
-
*
|
|
439
|
+
* Optional generic metadata associated with the structured schema.
|
|
440
|
+
* This can store any additional information relevant to tooling, UI generation,
|
|
441
|
+
* or specific domain requirements that are not covered by other properties.
|
|
442
|
+
* @example `{ graphqlType: "Address", apiEndpoint: "/api/addresses" }`
|
|
467
443
|
*/
|
|
468
444
|
metadata?: Record<string, any>;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Defines a structured nested schema that represents an object with defined fields.
|
|
472
|
-
* This is the traditional way of defining complex data structures within the schema.
|
|
473
|
-
*/
|
|
474
|
-
| {
|
|
445
|
+
} & ({
|
|
475
446
|
/**
|
|
476
|
-
*
|
|
477
|
-
*
|
|
447
|
+
* Optional constraints for additional validation rules that apply to the entire structured schema.
|
|
448
|
+
* These constraints provide an extra layer of data integrity beyond basic type checking.
|
|
449
|
+
* They are less strictly necessary when using discriminated field sets (`fields` as an array),
|
|
450
|
+
* as much of the variant logic can be enforced structurally through the `when` clauses.
|
|
478
451
|
*/
|
|
479
|
-
|
|
452
|
+
constraints?: SchemaConstraint<any>;
|
|
480
453
|
/**
|
|
481
454
|
* Indicates whether this schema represents a standalone entity (`true`) or is embedded (`false`).
|
|
482
455
|
* - When `true` (`concrete: true`), the schema is treated as a distinct, fixed-structure entity,
|
|
@@ -521,27 +494,12 @@ type NestedSchemaDefinition<T> = {
|
|
|
521
494
|
value: any;
|
|
522
495
|
};
|
|
523
496
|
}>;
|
|
497
|
+
} | (Pick<FieldDefinition<T>, "name" | "default" | "schema" | "itemsType" | "constraints"> & {
|
|
524
498
|
/**
|
|
525
|
-
*
|
|
526
|
-
* These constraints provide an extra layer of data integrity beyond basic type checking.
|
|
527
|
-
* They are less strictly necessary when using discriminated field sets (`fields` as an array),
|
|
528
|
-
* as much of the variant logic can be enforced structurally through the `when` clauses.
|
|
529
|
-
*/
|
|
530
|
-
constraints?: SchemaConstraint<any>;
|
|
531
|
-
/**
|
|
532
|
-
* Defines database indexes for the fields within this nested schema.
|
|
533
|
-
* This is primarily applicable when `concrete` is `true`, indicating that the schema
|
|
534
|
-
* maps directly to a persistent data store table. Indexes help optimize data retrieval.
|
|
535
|
-
*/
|
|
536
|
-
indexes?: IndexDefinition[];
|
|
537
|
-
/**
|
|
538
|
-
* Optional generic metadata associated with the structured schema.
|
|
539
|
-
* This can store any additional information relevant to tooling, UI generation,
|
|
540
|
-
* or specific domain requirements that are not covered by other properties.
|
|
541
|
-
* @example `{ graphqlType: "Address", apiEndpoint: "/api/addresses" }`
|
|
499
|
+
* The basic primitive type that this literal schema represents.
|
|
542
500
|
*/
|
|
543
|
-
|
|
544
|
-
});
|
|
501
|
+
type: "string" | "number" | "boolean" | "array" | "set" | "enum" | "record";
|
|
502
|
+
}));
|
|
545
503
|
/**
|
|
546
504
|
* Defines a complete schema, intended as an atomic unit within a larger domain model.
|
|
547
505
|
*
|