@objectstack/objectql 3.0.0 → 3.0.2

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/objectql@3.0.0 build /home/runner/work/spec/spec/packages/objectql
2
+ > @objectstack/objectql@3.0.2 build /home/runner/work/spec/spec/packages/objectql
3
3
  > tsup --config ../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.mjs 75.55 KB
14
- ESM dist/index.mjs.map 152.89 KB
15
- ESM ⚡️ Build success in 120ms
16
- CJS dist/index.js 77.09 KB
17
- CJS dist/index.js.map 153.77 KB
18
- CJS ⚡️ Build success in 127ms
13
+ ESM dist/index.mjs 79.69 KB
14
+ ESM dist/index.mjs.map 160.22 KB
15
+ ESM ⚡️ Build success in 136ms
16
+ CJS dist/index.js 81.23 KB
17
+ CJS dist/index.js.map 161.10 KB
18
+ CJS ⚡️ Build success in 137ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 13686ms
21
- DTS dist/index.d.mts 75.15 KB
22
- DTS dist/index.d.ts 75.15 KB
20
+ DTS ⚡️ Build success in 11624ms
21
+ DTS dist/index.d.mts 66.76 KB
22
+ DTS dist/index.d.ts 66.76 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @objectstack/objectql
2
2
 
3
+ ## 3.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [28985f5]
8
+ - @objectstack/spec@3.0.2
9
+ - @objectstack/core@3.0.2
10
+ - @objectstack/types@3.0.2
11
+
12
+ ## 3.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [389725a]
17
+ - @objectstack/spec@3.0.1
18
+ - @objectstack/core@3.0.1
19
+ - @objectstack/types@3.0.1
20
+
3
21
  ## 3.0.0
4
22
 
5
23
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -204,7 +204,7 @@ declare class SchemaRegistry {
204
204
  abstract: boolean;
205
205
  datasource: string;
206
206
  fields: Record<string, {
207
- type: "number" | "boolean" | "tags" | "date" | "lookup" | "file" | "json" | "code" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
207
+ type: "number" | "boolean" | "tags" | "date" | "lookup" | "file" | "json" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
208
208
  required: boolean;
209
209
  searchable: boolean;
210
210
  multiple: boolean;
@@ -262,7 +262,7 @@ declare class SchemaRegistry {
262
262
  allowScanning?: boolean | undefined;
263
263
  currencyConfig?: {
264
264
  precision: number;
265
- currencyMode: "fixed" | "dynamic";
265
+ currencyMode: "dynamic" | "fixed";
266
266
  defaultCurrency: string;
267
267
  } | undefined;
268
268
  vectorConfig?: {
@@ -270,7 +270,7 @@ declare class SchemaRegistry {
270
270
  distanceMetric: "cosine" | "euclidean" | "dotProduct" | "manhattan";
271
271
  normalized: boolean;
272
272
  indexed: boolean;
273
- indexType?: "flat" | "hnsw" | "ivfflat" | undefined;
273
+ indexType?: "hnsw" | "ivfflat" | "flat" | undefined;
274
274
  } | undefined;
275
275
  fileAttachmentConfig?: {
276
276
  virusScan: boolean;
@@ -332,7 +332,7 @@ declare class SchemaRegistry {
332
332
  } | undefined;
333
333
  maskingRule?: {
334
334
  field: string;
335
- strategy: "hash" | "redact" | "partial" | "tokenize" | "randomize" | "nullify" | "substitute";
335
+ strategy: "redact" | "partial" | "hash" | "tokenize" | "randomize" | "nullify" | "substitute";
336
336
  preserveFormat: boolean;
337
337
  preserveLength: boolean;
338
338
  pattern?: string | undefined;
@@ -1240,7 +1240,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
1240
1240
  label: string | undefined;
1241
1241
  required: boolean;
1242
1242
  readonly: boolean;
1243
- type: "number" | "boolean" | "tags" | "date" | "lookup" | "file" | "json" | "code" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
1243
+ type: "number" | "boolean" | "tags" | "date" | "lookup" | "file" | "json" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "code" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
1244
1244
  colSpan: number;
1245
1245
  }[];
1246
1246
  }[];
@@ -1327,6 +1327,7 @@ interface HookEntry {
1327
1327
  handler: HookHandler;
1328
1328
  object?: string | string[];
1329
1329
  priority: number;
1330
+ packageId?: string;
1330
1331
  }
1331
1332
  /**
1332
1333
  * Operation Context for Middleware Chain
@@ -1396,6 +1397,7 @@ declare class ObjectQL implements IDataEngine {
1396
1397
  registerHook(event: string, handler: HookHandler, options?: {
1397
1398
  object?: string | string[];
1398
1399
  priority?: number;
1400
+ packageId?: string;
1399
1401
  }): void;
1400
1402
  triggerHooks(event: string, context: HookContext): Promise<void>;
1401
1403
  /**
@@ -1463,270 +1465,7 @@ declare class ObjectQL implements IDataEngine {
1463
1465
  /**
1464
1466
  * Helper to get object definition
1465
1467
  */
1466
- getSchema(objectName: string): {
1467
- name: string;
1468
- active: boolean;
1469
- isSystem: boolean;
1470
- abstract: boolean;
1471
- datasource: string;
1472
- fields: Record<string, {
1473
- type: "number" | "boolean" | "tags" | "date" | "lookup" | "file" | "json" | "code" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
1474
- required: boolean;
1475
- searchable: boolean;
1476
- multiple: boolean;
1477
- unique: boolean;
1478
- deleteBehavior: "set_null" | "cascade" | "restrict";
1479
- auditTrail: boolean;
1480
- hidden: boolean;
1481
- readonly: boolean;
1482
- sortable: boolean;
1483
- index: boolean;
1484
- externalId: boolean;
1485
- name?: string | undefined;
1486
- label?: string | undefined;
1487
- description?: string | undefined;
1488
- format?: string | undefined;
1489
- defaultValue?: unknown;
1490
- maxLength?: number | undefined;
1491
- minLength?: number | undefined;
1492
- precision?: number | undefined;
1493
- scale?: number | undefined;
1494
- min?: number | undefined;
1495
- max?: number | undefined;
1496
- options?: {
1497
- label: string;
1498
- value: string;
1499
- color?: string | undefined;
1500
- default?: boolean | undefined;
1501
- }[] | undefined;
1502
- reference?: string | undefined;
1503
- referenceFilters?: string[] | undefined;
1504
- writeRequiresMasterRead?: boolean | undefined;
1505
- expression?: string | undefined;
1506
- summaryOperations?: {
1507
- object: string;
1508
- field: string;
1509
- function: "min" | "max" | "count" | "sum" | "avg";
1510
- } | undefined;
1511
- language?: string | undefined;
1512
- theme?: string | undefined;
1513
- lineNumbers?: boolean | undefined;
1514
- maxRating?: number | undefined;
1515
- allowHalf?: boolean | undefined;
1516
- displayMap?: boolean | undefined;
1517
- allowGeocoding?: boolean | undefined;
1518
- addressFormat?: "us" | "uk" | "international" | undefined;
1519
- colorFormat?: "hex" | "rgb" | "rgba" | "hsl" | undefined;
1520
- allowAlpha?: boolean | undefined;
1521
- presetColors?: string[] | undefined;
1522
- step?: number | undefined;
1523
- showValue?: boolean | undefined;
1524
- marks?: Record<string, string> | undefined;
1525
- barcodeFormat?: "qr" | "ean13" | "ean8" | "code128" | "code39" | "upca" | "upce" | undefined;
1526
- qrErrorCorrection?: "L" | "M" | "Q" | "H" | undefined;
1527
- displayValue?: boolean | undefined;
1528
- allowScanning?: boolean | undefined;
1529
- currencyConfig?: {
1530
- precision: number;
1531
- currencyMode: "fixed" | "dynamic";
1532
- defaultCurrency: string;
1533
- } | undefined;
1534
- vectorConfig?: {
1535
- dimensions: number;
1536
- distanceMetric: "cosine" | "euclidean" | "dotProduct" | "manhattan";
1537
- normalized: boolean;
1538
- indexed: boolean;
1539
- indexType?: "flat" | "hnsw" | "ivfflat" | undefined;
1540
- } | undefined;
1541
- fileAttachmentConfig?: {
1542
- virusScan: boolean;
1543
- virusScanOnUpload: boolean;
1544
- quarantineOnThreat: boolean;
1545
- allowMultiple: boolean;
1546
- allowReplace: boolean;
1547
- allowDelete: boolean;
1548
- requireUpload: boolean;
1549
- extractMetadata: boolean;
1550
- extractText: boolean;
1551
- versioningEnabled: boolean;
1552
- publicRead: boolean;
1553
- presignedUrlExpiry: number;
1554
- minSize?: number | undefined;
1555
- maxSize?: number | undefined;
1556
- allowedTypes?: string[] | undefined;
1557
- blockedTypes?: string[] | undefined;
1558
- allowedMimeTypes?: string[] | undefined;
1559
- blockedMimeTypes?: string[] | undefined;
1560
- virusScanProvider?: "custom" | "clamav" | "virustotal" | "metadefender" | undefined;
1561
- storageProvider?: string | undefined;
1562
- storageBucket?: string | undefined;
1563
- storagePrefix?: string | undefined;
1564
- imageValidation?: {
1565
- generateThumbnails: boolean;
1566
- preserveMetadata: boolean;
1567
- autoRotate: boolean;
1568
- minWidth?: number | undefined;
1569
- maxWidth?: number | undefined;
1570
- minHeight?: number | undefined;
1571
- maxHeight?: number | undefined;
1572
- aspectRatio?: string | undefined;
1573
- thumbnailSizes?: {
1574
- name: string;
1575
- width: number;
1576
- height: number;
1577
- crop: boolean;
1578
- }[] | undefined;
1579
- } | undefined;
1580
- maxVersions?: number | undefined;
1581
- } | undefined;
1582
- encryptionConfig?: {
1583
- enabled: boolean;
1584
- algorithm: "aes-256-gcm" | "aes-256-cbc" | "chacha20-poly1305";
1585
- keyManagement: {
1586
- provider: "local" | "aws-kms" | "azure-key-vault" | "gcp-kms" | "hashicorp-vault";
1587
- keyId?: string | undefined;
1588
- rotationPolicy?: {
1589
- enabled: boolean;
1590
- frequencyDays: number;
1591
- retainOldVersions: number;
1592
- autoRotate: boolean;
1593
- } | undefined;
1594
- };
1595
- scope: "field" | "table" | "record" | "database";
1596
- deterministicEncryption: boolean;
1597
- searchableEncryption: boolean;
1598
- } | undefined;
1599
- maskingRule?: {
1600
- field: string;
1601
- strategy: "hash" | "redact" | "partial" | "tokenize" | "randomize" | "nullify" | "substitute";
1602
- preserveFormat: boolean;
1603
- preserveLength: boolean;
1604
- pattern?: string | undefined;
1605
- roles?: string[] | undefined;
1606
- exemptRoles?: string[] | undefined;
1607
- } | undefined;
1608
- dependencies?: string[] | undefined;
1609
- cached?: {
1610
- enabled: boolean;
1611
- ttl: number;
1612
- invalidateOn: string[];
1613
- } | undefined;
1614
- dataQuality?: {
1615
- uniqueness: boolean;
1616
- completeness: number;
1617
- accuracy?: {
1618
- source: string;
1619
- threshold: number;
1620
- } | undefined;
1621
- } | undefined;
1622
- group?: string | undefined;
1623
- conditionalRequired?: string | undefined;
1624
- inlineHelpText?: string | undefined;
1625
- trackFeedHistory?: boolean | undefined;
1626
- caseSensitive?: boolean | undefined;
1627
- autonumberFormat?: string | undefined;
1628
- }>;
1629
- label?: string | undefined;
1630
- pluralLabel?: string | undefined;
1631
- description?: string | undefined;
1632
- icon?: string | undefined;
1633
- tags?: string[] | undefined;
1634
- tableName?: string | undefined;
1635
- indexes?: {
1636
- fields: string[];
1637
- type: "hash" | "btree" | "gin" | "gist" | "fulltext";
1638
- unique: boolean;
1639
- name?: string | undefined;
1640
- partial?: string | undefined;
1641
- }[] | undefined;
1642
- tenancy?: {
1643
- enabled: boolean;
1644
- strategy: "shared" | "isolated" | "hybrid";
1645
- tenantField: string;
1646
- crossTenantAccess: boolean;
1647
- } | undefined;
1648
- softDelete?: {
1649
- enabled: boolean;
1650
- field: string;
1651
- cascadeDelete: boolean;
1652
- } | undefined;
1653
- versioning?: {
1654
- enabled: boolean;
1655
- strategy: "snapshot" | "delta" | "event-sourcing";
1656
- versionField: string;
1657
- retentionDays?: number | undefined;
1658
- } | undefined;
1659
- partitioning?: {
1660
- enabled: boolean;
1661
- strategy: "hash" | "range" | "list";
1662
- key: string;
1663
- interval?: string | undefined;
1664
- } | undefined;
1665
- cdc?: {
1666
- enabled: boolean;
1667
- events: ("update" | "delete" | "insert")[];
1668
- destination: string;
1669
- } | undefined;
1670
- validations?: _objectstack_spec_data.BaseValidationRuleShape[] | undefined;
1671
- stateMachines?: Record<string, {
1672
- id: string;
1673
- initial: string;
1674
- states: Record<string, StateNodeConfig>;
1675
- description?: string | undefined;
1676
- contextSchema?: Record<string, unknown> | undefined;
1677
- on?: Record<string, string | {
1678
- target?: string | undefined;
1679
- cond?: string | {
1680
- type: string;
1681
- params?: Record<string, unknown> | undefined;
1682
- } | undefined;
1683
- actions?: (string | {
1684
- type: string;
1685
- params?: Record<string, unknown> | undefined;
1686
- })[] | undefined;
1687
- description?: string | undefined;
1688
- } | {
1689
- target?: string | undefined;
1690
- cond?: string | {
1691
- type: string;
1692
- params?: Record<string, unknown> | undefined;
1693
- } | undefined;
1694
- actions?: (string | {
1695
- type: string;
1696
- params?: Record<string, unknown> | undefined;
1697
- })[] | undefined;
1698
- description?: string | undefined;
1699
- }[]> | undefined;
1700
- }> | undefined;
1701
- displayNameField?: string | undefined;
1702
- recordName?: {
1703
- type: "text" | "autonumber";
1704
- displayFormat?: string | undefined;
1705
- startNumber?: number | undefined;
1706
- } | undefined;
1707
- titleFormat?: string | undefined;
1708
- compactLayout?: string[] | undefined;
1709
- search?: {
1710
- fields: string[];
1711
- displayFields?: string[] | undefined;
1712
- filters?: string[] | undefined;
1713
- } | undefined;
1714
- enable?: {
1715
- trackHistory: boolean;
1716
- searchable: boolean;
1717
- apiEnabled: boolean;
1718
- files: boolean;
1719
- feeds: boolean;
1720
- activities: boolean;
1721
- trash: boolean;
1722
- mru: boolean;
1723
- clone: boolean;
1724
- apiMethods?: ("search" | "list" | "update" | "delete" | "upsert" | "history" | "get" | "create" | "bulk" | "aggregate" | "restore" | "purge" | "import" | "export")[] | undefined;
1725
- } | undefined;
1726
- recordTypes?: string[] | undefined;
1727
- sharingModel?: "full" | "private" | "read" | "read_write" | undefined;
1728
- keyPrefix?: string | undefined;
1729
- } | undefined;
1468
+ getSchema(objectName: string): ServiceObject | undefined;
1730
1469
  /**
1731
1470
  * Resolve an object name to its Fully Qualified Name (FQN).
1732
1471
  *
@@ -1756,6 +1495,58 @@ declare class ObjectQL implements IDataEngine {
1756
1495
  count(object: string, query?: DataEngineCountOptions): Promise<number>;
1757
1496
  aggregate(object: string, query: DataEngineAggregateOptions): Promise<any[]>;
1758
1497
  execute(command: any, options?: Record<string, any>): Promise<any>;
1498
+ /**
1499
+ * Register a single object definition.
1500
+ *
1501
+ * Proxies to SchemaRegistry.registerObject() with sensible defaults.
1502
+ * Fields without a `name` property are auto-assigned from their key.
1503
+ */
1504
+ registerObject(schema: ServiceObject, packageId?: string, namespace?: string): string;
1505
+ /**
1506
+ * Unregister a single object by name.
1507
+ */
1508
+ unregisterObject(name: string, packageId?: string): void;
1509
+ /**
1510
+ * Get an object definition by name.
1511
+ * Alias for getSchema() — matches @objectql/core API.
1512
+ */
1513
+ getObject(name: string): ServiceObject | undefined;
1514
+ /**
1515
+ * Get all registered object configs as a name→config map.
1516
+ * Matches @objectql/core getConfigs() API.
1517
+ */
1518
+ getConfigs(): Record<string, ServiceObject>;
1519
+ /**
1520
+ * Get a registered driver by datasource name.
1521
+ *
1522
+ * Unlike the private getDriver() (which resolves by object name),
1523
+ * this method directly looks up a driver by its registered name.
1524
+ */
1525
+ getDriverByName(name: string): DriverInterface | undefined;
1526
+ /**
1527
+ * Get a registered driver by datasource name.
1528
+ * Alias matching @objectql/core datasource() API.
1529
+ *
1530
+ * @throws Error if the datasource is not found
1531
+ */
1532
+ datasource(name: string): DriverInterface;
1533
+ /**
1534
+ * Register a hook handler.
1535
+ * Convenience alias for registerHook() matching @objectql/core on() API.
1536
+ *
1537
+ * Usage:
1538
+ * ql.on('beforeInsert', 'user', async (ctx) => { ... });
1539
+ */
1540
+ on(event: string, objectName: string, handler: (ctx: HookContext) => Promise<void> | void, packageId?: string): void;
1541
+ /**
1542
+ * Remove all hooks, actions, and objects contributed by a package.
1543
+ */
1544
+ removePackage(packageId: string): void;
1545
+ /**
1546
+ * Gracefully shut down the engine, disconnecting all drivers.
1547
+ * Alias for destroy() — matches @objectql/core close() API.
1548
+ */
1549
+ close(): Promise<void>;
1759
1550
  /**
1760
1551
  * Create a scoped execution context bound to this engine.
1761
1552
  *
@@ -1765,6 +1556,27 @@ declare class ObjectQL implements IDataEngine {
1765
1556
  * await users.find({ filter: { status: 'active' } });
1766
1557
  */
1767
1558
  createContext(ctx: Partial<ExecutionContext>): ScopedContext;
1559
+ /**
1560
+ * Static factory: create a fully configured ObjectQL instance.
1561
+ *
1562
+ * Matches @objectql/core's `new ObjectQL(config)` pattern but also
1563
+ * registers drivers and objects, then calls init().
1564
+ *
1565
+ * Usage:
1566
+ * const ql = await ObjectQL.create({
1567
+ * datasources: { default: myDriver },
1568
+ * objects: { user: { name: 'user', fields: { ... } } }
1569
+ * });
1570
+ */
1571
+ static create(config: {
1572
+ datasources?: Record<string, DriverInterface>;
1573
+ objects?: Record<string, ServiceObject>;
1574
+ hooks?: Array<{
1575
+ event: string;
1576
+ object: string;
1577
+ handler: (ctx: HookContext) => Promise<void> | void;
1578
+ }>;
1579
+ }): Promise<ObjectQL>;
1768
1580
  }
1769
1581
  /**
1770
1582
  * Repository scoped to a single object, bound to an execution context.