dyna-record 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -61,7 +61,7 @@ import DynaRecord, {
61
61
  SortKey
62
62
  } from "dyna-record";
63
63
 
64
- @Table({ name: "my-table", delimiter: "#" })
64
+ @Table({ name: "my-table" })
65
65
  abstract class MyTable extends DynaRecord {
66
66
  @PartitionKeyAttribute({ alias: "PK" })
67
67
  public readonly pk: PartitionKey;
@@ -71,7 +71,7 @@ abstract class MyTable extends DynaRecord {
71
71
  }
72
72
  ```
73
73
 
74
- #### Customizing the default field table aliases
74
+ #### Customizing the default field table aliases or delimiter
75
75
 
76
76
  ```typescript
77
77
  import DynaRecord, {
@@ -84,7 +84,7 @@ import DynaRecord, {
84
84
 
85
85
  @Table({
86
86
  name: "mock-table",
87
- delimiter: "#",
87
+ delimiter: "|",
88
88
  defaultFields: {
89
89
  id: { alias: "Id" },
90
90
  type: { alias: "Type" },
@@ -14,7 +14,7 @@ interface DynaRecordBase {
14
14
  * Entities extending `DynaRecord` can utilize these operations to interact with their corresponding records in the database, including handling relationships between different entities.
15
15
  * @example
16
16
  * ```typescript
17
- * @Table({ name: "my-table", delimiter: "#" })
17
+ * @Table({ name: "my-table" })
18
18
  * abstract class MyTable extends DynaRecord {
19
19
  * @PartitionKeyAttribute()
20
20
  * public readonly pk: PartitionKey;
@@ -79,7 +79,7 @@ const utils_1 = require("./utils");
79
79
  * Entities extending `DynaRecord` can utilize these operations to interact with their corresponding records in the database, including handling relationships between different entities.
80
80
  * @example
81
81
  * ```typescript
82
- * @Table({ name: "my-table", delimiter: "#" })
82
+ * @Table({ name: "my-table" })
83
83
  * abstract class MyTable extends DynaRecord {
84
84
  * @PartitionKeyAttribute()
85
85
  * public readonly pk: PartitionKey;
@@ -10,7 +10,7 @@ import type DynaRecord from "../DynaRecord";
10
10
  *
11
11
  * Usage example:
12
12
  * ```typescript
13
- * @Table({ name: 'my-table', delimiter: '"#",' })
13
+ * @Table({ name: 'my-table' })
14
14
  * class MyTable extends DynaRecord {
15
15
  * // User entity implementation
16
16
  * }
@@ -14,7 +14,7 @@ const metadata_1 = __importDefault(require("../metadata"));
14
14
  *
15
15
  * Usage example:
16
16
  * ```typescript
17
- * @Table({ name: 'my-table', delimiter: '"#",' })
17
+ * @Table({ name: 'my-table' })
18
18
  * class MyTable extends DynaRecord {
19
19
  * // User entity implementation
20
20
  * }
@@ -16,7 +16,7 @@ export declare const tableDefaultFields: Record<DefaultFields, {
16
16
  * The metadata includes the partition and sort key attributes of the table, which are essential for database operations. It also provides a mechanism to include default attributes and their mappings, supporting common fields like `id`, `type`, `createdAt`, and `updatedAt`, along with their serialization strategies, particularly for date fields.
17
17
  *
18
18
  * @property {string} name - The name of the table.
19
- * @property {string} delimiter - A delimiter used in the table's composite keys.
19
+ * @property {string} delimiter - A delimiter used in the table's composite keys. Defaults to `#`
20
20
  * @property {Record<DefaultFields, AttributeMetadata>} defaultAttributes - A record of default attributes for the entity, keyed by entity field names.
21
21
  * @property {Record<string, AttributeMetadata>} defaultTableAttributes - A record of default attributes for the table, keyed by table field aliases.
22
22
  * @property {AttributeMetadata} partitionKeyAttribute - Metadata for the table's partition key attribute.
@@ -20,7 +20,7 @@ exports.tableDefaultFields = {
20
20
  * The metadata includes the partition and sort key attributes of the table, which are essential for database operations. It also provides a mechanism to include default attributes and their mappings, supporting common fields like `id`, `type`, `createdAt`, and `updatedAt`, along with their serialization strategies, particularly for date fields.
21
21
  *
22
22
  * @property {string} name - The name of the table.
23
- * @property {string} delimiter - A delimiter used in the table's composite keys.
23
+ * @property {string} delimiter - A delimiter used in the table's composite keys. Defaults to `#`
24
24
  * @property {Record<DefaultFields, AttributeMetadata>} defaultAttributes - A record of default attributes for the entity, keyed by entity field names.
25
25
  * @property {Record<string, AttributeMetadata>} defaultTableAttributes - A record of default attributes for the table, keyed by table field aliases.
26
26
  * @property {AttributeMetadata} partitionKeyAttribute - Metadata for the table's partition key attribute.
@@ -56,7 +56,7 @@ class TableMetadata {
56
56
  constructor(options) {
57
57
  const defaultAttrMeta = this.buildDefaultAttributesMetadata(options);
58
58
  this.name = options.name;
59
- this.delimiter = options.delimiter;
59
+ this.delimiter = options.delimiter ?? "#";
60
60
  this.defaultAttributes = defaultAttrMeta.entityDefaults;
61
61
  this.defaultTableAttributes = defaultAttrMeta.tableDefaults;
62
62
  // Placeholders, these are set later
@@ -45,8 +45,13 @@ export type DefaultFields = {
45
45
  export type TableDefaultFields = Record<DefaultFields, Pick<AttributeMetadata, "alias">>;
46
46
  /**
47
47
  * Options for configuring table metadata, including the table name, delimiter, and default fields.
48
+ *
49
+ * @remarks
50
+ * - **name**: The table name (required).
51
+ * - **delimiter**: An optional character used to separate fields in the table. If not provided, it defaults to `'#'`.
52
+ * - **defaultFields**: An optional mapping of default fields to their attribute metadata table aliases.
48
53
  */
49
- export type TableMetadataOptions = Pick<TableMetadata, "name" | "delimiter"> & {
54
+ export type TableMetadataOptions = Pick<TableMetadata, "name"> & Partial<Pick<TableMetadata, "delimiter">> & {
50
55
  defaultFields?: Partial<TableDefaultFields>;
51
56
  };
52
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/metadata/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACd,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,OAAO,CACtD,oBAAoB,EACpB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AAE,GAAG,KAAK,0BAA0B,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,gBAAgB,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,qBAAqB,GACrB,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dyna-record",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Typescript Data Modeler and ORM for Dynamo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",