@jaypie/dynamodb 0.1.3 → 0.3.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.
@@ -1,3 +1,4 @@
1
+ import type { FabricModel } from "@jaypie/fabric";
1
2
  /**
2
3
  * DynamoDB client configuration
3
4
  */
@@ -15,7 +16,7 @@ export interface DynamoClientConfig {
15
16
  tableName?: string;
16
17
  }
17
18
  /**
18
- * Parent reference for calculating OU
19
+ * Parent reference for calculating scope
19
20
  */
20
21
  export interface ParentReference {
21
22
  id: string;
@@ -37,13 +38,13 @@ export interface BaseQueryOptions {
37
38
  startKey?: Record<string, unknown>;
38
39
  }
39
40
  /**
40
- * Parameters for queryByOu
41
+ * Parameters for queryByScope
41
42
  */
42
- export interface QueryByOuParams extends BaseQueryOptions {
43
+ export interface QueryByScopeParams extends BaseQueryOptions {
43
44
  /** The entity model name */
44
45
  model: string;
45
- /** The organizational unit (APEX or "{parent.model}#{parent.id}") */
46
- ou: string;
46
+ /** The scope (APEX or "{parent.model}#{parent.id}") */
47
+ scope: string;
47
48
  }
48
49
  /**
49
50
  * Parameters for queryByAlias
@@ -57,8 +58,8 @@ export interface QueryByAliasParams {
57
58
  deleted?: boolean;
58
59
  /** The entity model name */
59
60
  model: string;
60
- /** The organizational unit */
61
- ou: string;
61
+ /** The scope */
62
+ scope: string;
62
63
  }
63
64
  /**
64
65
  * Parameters for queryByClass
@@ -66,8 +67,8 @@ export interface QueryByAliasParams {
66
67
  export interface QueryByClassParams extends BaseQueryOptions {
67
68
  /** The entity model name */
68
69
  model: string;
69
- /** The organizational unit */
70
- ou: string;
70
+ /** The scope */
71
+ scope: string;
71
72
  /** The category classification */
72
73
  recordClass: string;
73
74
  }
@@ -77,8 +78,8 @@ export interface QueryByClassParams extends BaseQueryOptions {
77
78
  export interface QueryByTypeParams extends BaseQueryOptions {
78
79
  /** The entity model name */
79
80
  model: string;
80
- /** The organizational unit */
81
- ou: string;
81
+ /** The scope */
82
+ scope: string;
82
83
  /** The type classification */
83
84
  type: string;
84
85
  }
@@ -92,47 +93,44 @@ export interface QueryByXidParams {
92
93
  deleted?: boolean;
93
94
  /** The entity model name */
94
95
  model: string;
95
- /** The organizational unit */
96
- ou: string;
96
+ /** The scope */
97
+ scope: string;
97
98
  /** The external ID */
98
99
  xid: string;
99
100
  }
100
101
  /**
101
102
  * Result of a query operation
102
103
  */
103
- export interface QueryResult<T = FabricEntity> {
104
+ export interface QueryResult<T = StorableEntity> {
104
105
  /** Array of matching entities */
105
106
  items: T[];
106
107
  /** Pagination cursor for next page (undefined if no more results) */
107
108
  lastEvaluatedKey?: Record<string, unknown>;
108
109
  }
109
110
  /**
110
- * Base entity interface for DynamoDB single-table design
111
+ * Entity with required fields for DynamoDB storage.
112
+ *
113
+ * Extends FabricModel from @jaypie/fabric with:
114
+ * - Required storage fields (id, model, name, scope, sequence)
115
+ * - String timestamps (DynamoDB uses ISO 8601 strings, not Date objects)
116
+ * - GSI index keys (auto-populated by indexEntity)
111
117
  */
112
- export interface FabricEntity {
118
+ export interface StorableEntity extends Omit<FabricModel, "archivedAt" | "createdAt" | "deletedAt" | "updatedAt"> {
113
119
  /** Partition key (e.g., "record", "message") */
114
120
  model: string;
115
121
  /** Sort key (UUID) */
116
122
  id: string;
117
123
  /** Human-readable name */
118
124
  name: string;
119
- /** Organizational unit: APEX ("@") or "{parent.model}#{parent.id}" */
120
- ou: string;
125
+ /** Scope: APEX ("@") or "{parent.model}#{parent.id}" */
126
+ scope: string;
121
127
  /** Timestamp for chronological ordering (Date.now()) */
122
128
  sequence: number;
123
129
  indexAlias?: string;
124
130
  indexClass?: string;
125
- indexOu?: string;
131
+ indexScope?: string;
126
132
  indexType?: string;
127
133
  indexXid?: string;
128
- /** Human-friendly slug/alias */
129
- alias?: string;
130
- /** Category classification */
131
- class?: string;
132
- /** Type classification */
133
- type?: string;
134
- /** External ID for integration with external systems */
135
- xid?: string;
136
134
  createdAt: string;
137
135
  updatedAt: string;
138
136
  /** Archive timestamp (for inactive but preserved records) */
@@ -1,9 +1,6 @@
1
- export declare const APEX = "@";
2
- export declare const SEPARATOR = "#";
1
+ export { APEX, ARCHIVED_SUFFIX, DELETED_SUFFIX, SEPARATOR, } from "@jaypie/fabric";
3
2
  export declare const INDEX_ALIAS = "indexAlias";
4
3
  export declare const INDEX_CLASS = "indexClass";
5
- export declare const INDEX_OU = "indexOu";
4
+ export declare const INDEX_SCOPE = "indexScope";
6
5
  export declare const INDEX_TYPE = "indexType";
7
6
  export declare const INDEX_XID = "indexXid";
8
- export declare const ARCHIVED_SUFFIX = "#archived";
9
- export declare const DELETED_SUFFIX = "#deleted";
@@ -1,40 +1,40 @@
1
- import type { FabricEntity } from "./types.js";
1
+ import type { StorableEntity } from "./types.js";
2
2
  /**
3
3
  * Get a single entity by primary key
4
4
  */
5
- export declare const getEntity: import("@jaypie/vocabulary").ServiceHandlerFunction<Record<string, unknown>, FabricEntity | null>;
5
+ export declare const getEntity: import("@jaypie/fabric").Service<Record<string, unknown>, StorableEntity | null>;
6
6
  /**
7
7
  * Put (create or replace) an entity
8
8
  * Auto-populates GSI index keys via indexEntity
9
9
  *
10
- * Note: This is a regular async function (not serviceHandler) because it accepts
11
- * complex FabricEntity objects that can't be coerced by vocabulary's type system.
10
+ * Note: This is a regular async function (not fabricService) because it accepts
11
+ * complex StorableEntity objects that can't be coerced by vocabulary's type system.
12
12
  */
13
13
  export declare function putEntity({ entity, }: {
14
- entity: FabricEntity;
15
- }): Promise<FabricEntity>;
14
+ entity: StorableEntity;
15
+ }): Promise<StorableEntity>;
16
16
  /**
17
17
  * Update an existing entity
18
18
  * Auto-populates GSI index keys and sets updatedAt
19
19
  *
20
- * Note: This is a regular async function (not serviceHandler) because it accepts
21
- * complex FabricEntity objects that can't be coerced by vocabulary's type system.
20
+ * Note: This is a regular async function (not fabricService) because it accepts
21
+ * complex StorableEntity objects that can't be coerced by vocabulary's type system.
22
22
  */
23
23
  export declare function updateEntity({ entity, }: {
24
- entity: FabricEntity;
25
- }): Promise<FabricEntity>;
24
+ entity: StorableEntity;
25
+ }): Promise<StorableEntity>;
26
26
  /**
27
27
  * Soft delete an entity by setting deletedAt timestamp
28
28
  * Re-indexes with appropriate suffix based on archived/deleted state
29
29
  */
30
- export declare const deleteEntity: import("@jaypie/vocabulary").ServiceHandlerFunction<Record<string, unknown>, boolean>;
30
+ export declare const deleteEntity: import("@jaypie/fabric").Service<Record<string, unknown>, boolean>;
31
31
  /**
32
32
  * Archive an entity by setting archivedAt timestamp
33
33
  * Re-indexes with appropriate suffix based on archived/deleted state
34
34
  */
35
- export declare const archiveEntity: import("@jaypie/vocabulary").ServiceHandlerFunction<Record<string, unknown>, boolean>;
35
+ export declare const archiveEntity: import("@jaypie/fabric").Service<Record<string, unknown>, boolean>;
36
36
  /**
37
37
  * Hard delete an entity (permanently removes from table)
38
38
  * Use with caution - prefer deleteEntity for soft delete
39
39
  */
40
- export declare const destroyEntity: import("@jaypie/vocabulary").ServiceHandlerFunction<Record<string, unknown>, boolean>;
40
+ export declare const destroyEntity: import("@jaypie/fabric").Service<Record<string, unknown>, boolean>;
@@ -1,8 +1,10 @@
1
1
  export { getDocClient, getTableName, initClient, isInitialized, resetClient, } from "./client.js";
2
- export { APEX, ARCHIVED_SUFFIX, DELETED_SUFFIX, INDEX_ALIAS, INDEX_CLASS, INDEX_OU, INDEX_TYPE, INDEX_XID, SEPARATOR, } from "./constants.js";
2
+ export { APEX, ARCHIVED_SUFFIX, DELETED_SUFFIX, INDEX_ALIAS, INDEX_CLASS, INDEX_SCOPE, INDEX_TYPE, INDEX_XID, SEPARATOR, } from "./constants.js";
3
3
  export { archiveEntity, deleteEntity, destroyEntity, getEntity, putEntity, updateEntity, } from "./entities.js";
4
- export { buildIndexAlias, buildIndexClass, buildIndexOu, buildIndexType, buildIndexXid, calculateOu, indexEntity, } from "./keyBuilders.js";
5
- export { queryByAlias, queryByClass, queryByOu, queryByType, queryByXid, } from "./queries.js";
4
+ export { buildCompositeKey, buildIndexAlias, buildIndexClass, buildIndexScope, buildIndexType, buildIndexXid, calculateScope, DEFAULT_INDEXES, indexEntity, } from "./keyBuilders.js";
5
+ export { queryByAlias, queryByClass, queryByScope, queryByType, queryByXid, } from "./queries.js";
6
+ export { query } from "./query.js";
7
+ export type { QueryParams } from "./query.js";
6
8
  export { exportEntities, exportEntitiesToJson, seedEntities, seedEntityIfNotExists, } from "./seedExport.js";
7
- export type { BaseQueryOptions, DynamoClientConfig, FabricEntity, ParentReference, QueryResult, } from "./types.js";
9
+ export type { BaseQueryOptions, DynamoClientConfig, ParentReference, QueryResult, StorableEntity, } from "./types.js";
8
10
  export type { ExportResult, SeedOptions, SeedResult } from "./seedExport.js";