declastruct 1.5.0 → 1.5.1

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,4 +1,4 @@
1
- import { type DomainEntity, DomainLiteral, type Ref, type Refable, type RefByPrimary, type RefByUnique } from 'domain-objects';
1
+ import { DomainLiteral, type Ref, type Refable, type RefByPrimary, type RefByUnique } from 'domain-objects';
2
2
  import type { HasMetadata } from 'type-fns';
3
3
  /**
4
4
  * .what = standardized data access interface for any resource type
@@ -7,9 +7,9 @@ import type { HasMetadata } from 'type-fns';
7
7
  *
8
8
  * .note =
9
9
  * - TResourceClass is the class constructor (e.g., typeof MyResource) with static unique/primary properties
10
- * - uses method syntax in the get & set for bivariance, to enable assignment to DeclastructDao<any, any, any>
10
+ * - uses method syntax in the get & set for bivariance, to enable assignment to DeclastructDao<any, any>
11
11
  */
12
- export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext = never> {
12
+ export interface DeclastructDao<TResourceClass extends Refable<any, any, any>, TContext = never> {
13
13
  /**
14
14
  * .what = the domain object class this dao operates on
15
15
  * .why = enables downstream operations (like getRefByPrimary) to access static properties
@@ -29,19 +29,19 @@ export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceCl
29
29
  * .what = fetch by unique keys
30
30
  * .why = enables idempotent lookups via natural keys
31
31
  */
32
- byUnique(input: RefByUnique<TResourceClass>, context: TContext): Promise<TResource | null>;
32
+ byUnique(input: RefByUnique<TResourceClass>, context: TContext): Promise<InstanceType<TResourceClass> | null>;
33
33
  /**
34
34
  * .what = fetch by primary keys
35
35
  * .why = enables efficient lookups when primary key is known
36
36
  *
37
37
  * .note = set to null if resource lacks primary keys (forces explicit decision)
38
38
  */
39
- byPrimary: null | ((input: RefByPrimary<TResourceClass>, context: TContext) => Promise<TResource | null>);
39
+ byPrimary: null | ((input: RefByPrimary<TResourceClass>, context: TContext) => Promise<InstanceType<TResourceClass> | null>);
40
40
  /**
41
41
  * .what = fetch by any supported reference type
42
42
  * .why = enables flexible lookups when ref type is not known at compile time
43
43
  */
44
- byRef(input: Ref<TResourceClass>, context: TContext): Promise<TResource | null>;
44
+ byRef(input: Ref<TResourceClass>, context: TContext): Promise<InstanceType<TResourceClass> | null>;
45
45
  };
46
46
  /**
47
47
  * .what = ref resolution utilities for converting between ref types
@@ -75,14 +75,14 @@ export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceCl
75
75
  * .what = find or insert resource
76
76
  * .why = idempotent create - returns existing if found by unique keys, otherwise creates
77
77
  */
78
- finsert(input: TResource, context: TContext): Promise<HasMetadata<TResource>>;
78
+ finsert(input: InstanceType<TResourceClass>, context: TContext): Promise<HasMetadata<InstanceType<TResourceClass>>>;
79
79
  /**
80
80
  * .what = create or update resource
81
81
  * .why = idempotent upsert - creates if not found, updates if found
82
82
  *
83
83
  * .note = set to null if resource does not support updates
84
84
  */
85
- upsert: null | ((input: TResource, context: TContext) => Promise<HasMetadata<TResource>>);
85
+ upsert: null | ((input: InstanceType<TResourceClass>, context: TContext) => Promise<HasMetadata<InstanceType<TResourceClass>>>);
86
86
  /**
87
87
  * .what = delete resource
88
88
  * .why = removes resource from remote state
@@ -92,5 +92,5 @@ export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceCl
92
92
  delete: null | ((input: Ref<TResourceClass>, context: TContext) => Promise<void>);
93
93
  };
94
94
  }
95
- export declare class DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext> extends DomainLiteral<DeclastructDao<TResource, TResourceClass, TContext>> implements DeclastructDao<TResource, TResourceClass, TContext> {
95
+ export declare class DeclastructDao<TResourceClass extends Refable<any, any, any>, TContext> extends DomainLiteral<DeclastructDao<TResourceClass, TContext>> implements DeclastructDao<TResourceClass, TContext> {
96
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DeclastructDao.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.ts"],"names":[],"mappings":";;;AAAA,mDAOwB;AA2IxB,MAAa,cAKX,SAAQ,8BAAkE;CACT;AANnE,wCAMmE"}
1
+ {"version":3,"file":"DeclastructDao.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.ts"],"names":[],"mappings":";;;AAAA,mDAMwB;AA0IxB,MAAa,cAIX,SAAQ,8BAAuD;CACT;AALxD,wCAKwD"}
@@ -1,6 +1,6 @@
1
1
  import { DomainLiteral } from 'domain-objects';
2
2
  import type { DeclastructDao } from './DeclastructDao';
3
- export type DeclastructDaosShape<TContext> = Record<string, DeclastructDao<any, any, TContext>>;
3
+ export type DeclastructDaosShape<TContext> = Record<string, DeclastructDao<any, TContext>>;
4
4
  /**
5
5
  * .what = bundles all DAOs and lifecycle hooks for a specific infrastructure provider
6
6
  * .why = enables plug-and-play support for different infrastructure backends (AWS, GCP, Azure, etc)
@@ -10,6 +10,6 @@ export declare const getDaoByResource: ({ resource, providers, }: {
10
10
  resource: DomainEntity<any>;
11
11
  providers: DeclastructProvider<any, any>[];
12
12
  }) => {
13
- dao: DeclastructDao<DomainEntity<any>, any, any>;
13
+ dao: DeclastructDao<any, any>;
14
14
  context: any;
15
15
  };
@@ -1,12 +1,12 @@
1
- import { type DomainEntity, type Ref, type Refable, type RefByPrimary } from 'domain-objects';
1
+ import { type Ref, type Refable, type RefByPrimary } from 'domain-objects';
2
2
  import type { DeclastructDao } from '../../domain.objects/DeclastructDao';
3
3
  /**
4
4
  * .what = resolves any ref to RefByPrimary
5
5
  * .why = enables getting primary key from any ref type
6
6
  * .note = if ref is already RefByPrimary, returns as-is without db call
7
7
  */
8
- export declare const getRefByPrimary: <TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext extends Record<string, any>>(input: {
8
+ export declare const getRefByPrimary: <TResourceClass extends Refable<any, any, any>, TContext extends Record<string, any>>(input: {
9
9
  ref: Ref<TResourceClass>;
10
10
  }, context: {
11
- dao: DeclastructDao<TResource, TResourceClass, TContext>;
11
+ dao: DeclastructDao<TResourceClass, TContext>;
12
12
  } & TContext) => Promise<RefByPrimary<TResourceClass>>;
@@ -1 +1 @@
1
- {"version":3,"file":"getRefByPrimary.js","sourceRoot":"","sources":["../../../src/domain.operations/ref/getRefByPrimary.ts"],"names":[],"mappings":";;;AAAA,mDAQwB;AACxB,mDAA0E;AAI1E;;;;GAIG;AACI,MAAM,eAAe,GAAG,KAAK,EAKlC,KAEC,EACD,OAEY,EAC2B,EAAE;IACzC,wDAAwD;IACxD,IAAI,IAAA,+BAAc,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAE1E,yDAAyD;IACzD,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,mCAAmC;QACnC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAExE,8BAA8B;QAC9B,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,gCAAe,CAAC,kCAAkC,EAAE;gBAC5D,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC,CAAC;QAEL,wCAAwC;QACxC,OAAO,IAAA,6BAAY,EACjB,QAAwC,CACzC,CAAC;IACJ,CAAC;IAED,iCAAiC;IACjC,MAAM,IAAI,wCAAuB,CAAC,kBAAkB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AAlCW,QAAA,eAAe,mBAkC1B"}
1
+ {"version":3,"file":"getRefByPrimary.js","sourceRoot":"","sources":["../../../src/domain.operations/ref/getRefByPrimary.ts"],"names":[],"mappings":";;;AAAA,mDAOwB;AACxB,mDAA0E;AAI1E;;;;GAIG;AACI,MAAM,eAAe,GAAG,KAAK,EAIlC,KAEC,EACD,OAEY,EAC2B,EAAE;IACzC,wDAAwD;IACxD,IAAI,IAAA,+BAAc,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAE1E,yDAAyD;IACzD,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,mCAAmC;QACnC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAExE,8BAA8B;QAC9B,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,gCAAe,CAAC,kCAAkC,EAAE;gBAC5D,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC,CAAC;QAEL,wCAAwC;QACxC,OAAO,IAAA,6BAAY,EAAiB,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,iCAAiC;IACjC,MAAM,IAAI,wCAAuB,CAAC,kBAAkB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AA/BW,QAAA,eAAe,mBA+B1B"}
@@ -1,12 +1,12 @@
1
- import { type DomainEntity, type Ref, type Refable, type RefByUnique } from 'domain-objects';
1
+ import { type Ref, type Refable, type RefByUnique } from 'domain-objects';
2
2
  import type { DeclastructDao } from '../../domain.objects/DeclastructDao';
3
3
  /**
4
4
  * .what = resolves any ref to RefByUnique
5
5
  * .why = enables getting unique key from any ref type
6
6
  * .note = if ref is already RefByUnique, returns as-is without db call
7
7
  */
8
- export declare const getRefByUnique: <TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext extends Record<string, any>>(input: {
8
+ export declare const getRefByUnique: <TResourceClass extends Refable<any, any, any>, TContext extends Record<string, any>>(input: {
9
9
  ref: Ref<TResourceClass>;
10
10
  }, context: {
11
- dao: DeclastructDao<TResource, TResourceClass, TContext>;
11
+ dao: DeclastructDao<TResourceClass, TContext>;
12
12
  } & TContext) => Promise<RefByUnique<TResourceClass>>;
@@ -1 +1 @@
1
- {"version":3,"file":"getRefByUnique.js","sourceRoot":"","sources":["../../../src/domain.operations/ref/getRefByUnique.ts"],"names":[],"mappings":";;;AAAA,mDAQwB;AACxB,mDAA0E;AAI1E;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EAKjC,KAEC,EACD,OAEY,EAC0B,EAAE;IACxC,uDAAuD;IACvD,IAAI,IAAA,8BAAa,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAEzE,yDAAyD;IACzD,IAAI,IAAA,+BAAc,EAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACxD,gCAAgC;QAChC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS;YAChC,MAAM,IAAI,wCAAuB,CAC/B,uCAAuC,EACvC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CACnB,CAAC;QAEJ,oCAAoC;QACpC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEzE,8BAA8B;QAC9B,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,gCAAe,CAAC,mCAAmC,EAA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C,mCAAmC,EAAE;gBAC7D,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC,CAAC;QAEL,uCAAuC;QACvC,OAAO,IAAA,4BAAW,EAAiB,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,iCAAiC;IACjC,MAAM,IAAI,wCAAuB,CAAC,kBAAkB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AAtCW,QAAA,cAAc,kBAsCzB"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declastruct",
3
3
  "author": "ehmpathy",
4
4
  "description": "Add declarative control to any resource constructs. Declare, plan, and apply within an observable pit-of-success.",
5
- "version": "1.5.0",
5
+ "version": "1.5.1",
6
6
  "repository": "ehmpathy/declastruct",
7
7
  "homepage": "https://github.com/ehmpathy/declastruct",
8
8
  "keywords": [