@pattern-stack/codegen 0.17.1 → 0.18.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/CHANGELOG.md +36 -0
- package/README.md +106 -2
- package/dist/{chunk-SFQRETXJ.js → chunk-2VGVSL2D.js} +6 -6
- package/dist/{chunk-VNBC3VXM.js → chunk-3A34R6CI.js} +7 -7
- package/dist/{chunk-FVNAU7VO.js → chunk-7MMS36AN.js} +6 -6
- package/dist/{chunk-FWRL7BZ5.js → chunk-C5E7H553.js} +25 -15
- package/dist/chunk-C5E7H553.js.map +1 -0
- package/dist/{chunk-IOQMMH6C.js → chunk-CFFTPWHM.js} +79 -4
- package/dist/chunk-CFFTPWHM.js.map +1 -0
- package/dist/{chunk-HOIRY5XP.js → chunk-EWYI5GGJ.js} +10 -10
- package/dist/{chunk-BHZP6LOV.js → chunk-IN3EWFB4.js} +4 -4
- package/dist/{chunk-CZQUOIDY.js → chunk-J7JMVS2B.js} +4 -4
- package/dist/{chunk-KSTZIULO.js → chunk-K2I6XIK5.js} +4 -4
- package/dist/{chunk-T6SCOJF4.js → chunk-NXHL5YII.js} +4 -4
- package/dist/{chunk-JA7GJDNI.js → chunk-PKDS6QIJ.js} +4 -4
- package/dist/{chunk-MYQIQ27N.js → chunk-Q6LRJ4VI.js} +51 -2
- package/dist/chunk-Q6LRJ4VI.js.map +1 -0
- package/dist/{chunk-EJBK7I4F.js → chunk-R4BPUUB5.js} +3 -3
- package/dist/{chunk-4PFF3ED4.js → chunk-RKNW56RU.js} +5 -5
- package/dist/{chunk-SGSWVNNB.js → chunk-TBGTMALE.js} +4 -4
- package/dist/{chunk-GM3RMJIJ.js → chunk-VHAR2BGH.js} +4 -4
- package/dist/{chunk-DUMI2J5M.js → chunk-VQOAATIG.js} +4 -4
- package/dist/{chunk-HPS554L4.js → chunk-X6BP6LI5.js} +6 -6
- package/dist/{chunk-PSDVGPQR.js → chunk-YZLBU6O2.js} +9 -9
- package/dist/runtime/shared/openapi/index.js +3 -3
- package/dist/runtime/subsystems/analytics/analytics.module.js +2 -2
- package/dist/runtime/subsystems/analytics/index.js +4 -4
- package/dist/runtime/subsystems/auth/auth.module.js +3 -3
- package/dist/runtime/subsystems/auth/index.js +10 -10
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +2 -2
- package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +2 -2
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +6 -6
- package/dist/runtime/subsystems/bridge/bridge.module.js +17 -17
- package/dist/runtime/subsystems/bridge/index.js +24 -24
- package/dist/runtime/subsystems/cache/cache.module.js +1 -1
- package/dist/runtime/subsystems/cache/index.js +3 -3
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/events/events.module.js +6 -6
- package/dist/runtime/subsystems/events/generated/bus.js +2 -2
- package/dist/runtime/subsystems/events/generated/index.js +2 -2
- package/dist/runtime/subsystems/events/index.js +10 -10
- package/dist/runtime/subsystems/index.js +64 -64
- package/dist/runtime/subsystems/integration/index.js +10 -10
- package/dist/runtime/subsystems/integration/integration.module.js +2 -2
- package/dist/runtime/subsystems/jobs/index.js +21 -21
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +5 -5
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +2 -2
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +2 -2
- package/dist/runtime/subsystems/jobs/job-worker.d.ts +8 -0
- package/dist/runtime/subsystems/jobs/job-worker.js +3 -3
- package/dist/runtime/subsystems/jobs/job-worker.module.js +11 -11
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +9 -9
- package/dist/runtime/subsystems/jobs/pg-notify.d.ts +25 -1
- package/dist/runtime/subsystems/jobs/pg-notify.js +1 -1
- package/dist/src/cli/index.js +1408 -245
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.js +5 -5
- package/package.json +1 -1
- package/runtime/subsystems/jobs/job-worker.ts +29 -11
- package/runtime/subsystems/jobs/pg-notify.ts +63 -3
- package/src/config/locations.mjs +0 -6
- package/src/config/paths.mjs +0 -13
- package/templates/entity/new/prompt.js +12 -88
- package/dist/chunk-FWRL7BZ5.js.map +0 -1
- package/dist/chunk-IOQMMH6C.js.map +0 -1
- package/dist/chunk-MYQIQ27N.js.map +0 -1
- package/templates/entity/new/frontend/_inject-entities-entry.ejs.t +0 -7
- package/templates/entity/new/frontend/_inject-entities-import.ejs.t +0 -7
- package/templates/entity/new/frontend/collections/_ensure-anchor-collections.ejs.t +0 -10
- package/templates/entity/new/frontend/collections/_inject-index.ejs.t +0 -9
- package/templates/entity/new/frontend/collections/_inject-schema-import.ejs.t +0 -9
- package/templates/entity/new/frontend/collections/collection.ejs.t +0 -86
- package/templates/entity/new/frontend/collections/collections-base.ejs.t +0 -35
- package/templates/entity/new/frontend/entity/collection.ejs.t +0 -173
- package/templates/entity/new/frontend/entity/combined.ejs.t +0 -505
- package/templates/entity/new/frontend/entity/fields.ejs.t +0 -105
- package/templates/entity/new/frontend/entity/hooks.ejs.t +0 -74
- package/templates/entity/new/frontend/entity/index.ejs.t +0 -22
- package/templates/entity/new/frontend/entity/mutation-hooks.ejs.t +0 -85
- package/templates/entity/new/frontend/entity/mutations.ejs.t +0 -39
- package/templates/entity/new/frontend/entity/types.ejs.t +0 -60
- package/templates/entity/new/frontend/generated/_inject-index-export.ejs.t +0 -7
- package/templates/entity/new/frontend/generated/_inject-index-import.ejs.t +0 -7
- package/templates/entity/new/frontend/generated/_inject-index-registry.ejs.t +0 -7
- package/templates/entity/new/frontend/store/_inject-collection-import.ejs.t +0 -9
- package/templates/entity/new/frontend/store/_inject-collections.ejs.t +0 -9
- package/templates/entity/new/frontend/store/_inject-entity.ejs.t +0 -9
- package/templates/entity/new/frontend/store/_inject-import.ejs.t +0 -9
- package/templates/entity/new/frontend/store/_inject-lookups.ejs.t +0 -9
- package/templates/entity/new/frontend/store/_inject-resolve.ejs.t +0 -10
- package/templates/entity/new/frontend/store/hooks.ejs.t +0 -73
- package/templates/entity/new/frontend/unified-entity.ejs.t +0 -29
- /package/dist/{chunk-SFQRETXJ.js.map → chunk-2VGVSL2D.js.map} +0 -0
- /package/dist/{chunk-VNBC3VXM.js.map → chunk-3A34R6CI.js.map} +0 -0
- /package/dist/{chunk-FVNAU7VO.js.map → chunk-7MMS36AN.js.map} +0 -0
- /package/dist/{chunk-HOIRY5XP.js.map → chunk-EWYI5GGJ.js.map} +0 -0
- /package/dist/{chunk-BHZP6LOV.js.map → chunk-IN3EWFB4.js.map} +0 -0
- /package/dist/{chunk-CZQUOIDY.js.map → chunk-J7JMVS2B.js.map} +0 -0
- /package/dist/{chunk-KSTZIULO.js.map → chunk-K2I6XIK5.js.map} +0 -0
- /package/dist/{chunk-T6SCOJF4.js.map → chunk-NXHL5YII.js.map} +0 -0
- /package/dist/{chunk-JA7GJDNI.js.map → chunk-PKDS6QIJ.js.map} +0 -0
- /package/dist/{chunk-EJBK7I4F.js.map → chunk-R4BPUUB5.js.map} +0 -0
- /package/dist/{chunk-4PFF3ED4.js.map → chunk-RKNW56RU.js.map} +0 -0
- /package/dist/{chunk-SGSWVNNB.js.map → chunk-TBGTMALE.js.map} +0 -0
- /package/dist/{chunk-GM3RMJIJ.js.map → chunk-VHAR2BGH.js.map} +0 -0
- /package/dist/{chunk-DUMI2J5M.js.map → chunk-VQOAATIG.js.map} +0 -0
- /package/dist/{chunk-HPS554L4.js.map → chunk-X6BP6LI5.js.map} +0 -0
- /package/dist/{chunk-PSDVGPQR.js.map → chunk-YZLBU6O2.js.map} +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= generate.structure === 'entity-first' ? `${locations.frontendGenerated.path}/${name}/index.ts` : '' %>"
|
|
3
|
-
skip_if: <%= !frontendEnabled || (generate.structure !== 'entity-first') %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> - Entity Module
|
|
9
|
-
* Generated by entity codegen - do not edit directly
|
|
10
|
-
*
|
|
11
|
-
* Barrel export for all <%= className %> components
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export * from './types';
|
|
15
|
-
export * from './collection';
|
|
16
|
-
export * from './hooks';
|
|
17
|
-
<% if (generate.mutations && (exposeTrpc || exposeRepository)) { %>
|
|
18
|
-
export * from './mutations';
|
|
19
|
-
<% } %>
|
|
20
|
-
<% if (generate.fieldMetadata) { %>
|
|
21
|
-
export * from './fields';
|
|
22
|
-
<% } %>
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= generate.structure === 'entity-first' ? `${locations.frontendGenerated.path}/${generate.fileNaming === 'plural' ? plural : name}/mutation-hooks.ts` : generate.structure === 'concern-first' ? `${locations.frontendGenerated.path}/mutation-hooks/${generate.fileNaming === 'plural' ? plural : name}.ts` : '' %>"
|
|
3
|
-
skip_if: <%= !frontendEnabled || (generate.structure === 'monolithic' || !generate.mutations || !(exposeTrpc || exposeRepository)) %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> Mutation Hooks
|
|
9
|
-
* Generated by entity codegen - do not edit directly
|
|
10
|
-
*
|
|
11
|
-
* React hooks wrapping mutation functions with error state management
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { useState, useCallback } from 'react';
|
|
15
|
-
<%
|
|
16
|
-
// File name for imports depends on fileNaming config
|
|
17
|
-
const fileName = generate.fileNaming === 'plural' ? plural : name;
|
|
18
|
-
-%>
|
|
19
|
-
<% if (generate.structure === 'entity-first') { -%>
|
|
20
|
-
import { insert<%= className %>, update<%= className %>, delete<%= className %> } from './mutations';
|
|
21
|
-
import type { <%= className %> } from './types';
|
|
22
|
-
<% } else if (generate.structure === 'concern-first') { -%>
|
|
23
|
-
import { insert<%= className %>, update<%= className %>, delete<%= className %> } from '../mutations/<%= fileName %>';
|
|
24
|
-
import type { <%= className %> } from '../types/<%= fileName %>';
|
|
25
|
-
<% } -%>
|
|
26
|
-
|
|
27
|
-
type MutationHookResult<TFn extends (...args: any[]) => any> = {
|
|
28
|
-
mutate: TFn;
|
|
29
|
-
error: Error | null;
|
|
30
|
-
clearError: () => void;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function useCreate<%= className %>(): MutationHookResult<typeof insert<%= className %>> {
|
|
34
|
-
const [error, setError] = useState<Error | null>(null);
|
|
35
|
-
|
|
36
|
-
const mutate = useCallback<typeof insert<%= className %>>((data) => {
|
|
37
|
-
try {
|
|
38
|
-
insert<%= className %>(data);
|
|
39
|
-
setError(null);
|
|
40
|
-
} catch (err) {
|
|
41
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
42
|
-
setError(error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
const clearError = useCallback(() => setError(null), []);
|
|
48
|
-
return { mutate, error, clearError };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function useUpdate<%= className %>(): MutationHookResult<typeof update<%= className %>> {
|
|
52
|
-
const [error, setError] = useState<Error | null>(null);
|
|
53
|
-
|
|
54
|
-
const mutate = useCallback<typeof update<%= className %>>((id, fn) => {
|
|
55
|
-
try {
|
|
56
|
-
update<%= className %>(id, fn);
|
|
57
|
-
setError(null);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
60
|
-
setError(error);
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
const clearError = useCallback(() => setError(null), []);
|
|
66
|
-
return { mutate, error, clearError };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function useDelete<%= className %>(): MutationHookResult<typeof delete<%= className %>> {
|
|
70
|
-
const [error, setError] = useState<Error | null>(null);
|
|
71
|
-
|
|
72
|
-
const mutate = useCallback<typeof delete<%= className %>>((id) => {
|
|
73
|
-
try {
|
|
74
|
-
delete<%= className %>(id);
|
|
75
|
-
setError(null);
|
|
76
|
-
} catch (err) {
|
|
77
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
78
|
-
setError(error);
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}, []);
|
|
82
|
-
|
|
83
|
-
const clearError = useCallback(() => setError(null), []);
|
|
84
|
-
return { mutate, error, clearError };
|
|
85
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= generate.structure === 'entity-first' ? `${locations.frontendGenerated.path}/${name}/mutations.ts` : generate.structure === 'concern-first' ? `${locations.frontendGenerated.path}/mutations/${name}.ts` : '' %>"
|
|
3
|
-
skip_if: <%= !frontendEnabled || (generate.structure === 'monolithic' || !generate.mutations || !(exposeTrpc || exposeRepository)) %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> Mutations
|
|
9
|
-
* Generated by entity codegen - do not edit directly
|
|
10
|
-
*
|
|
11
|
-
* Optimistic update functions for <%= className %> entity
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
<% if (generate.structure === 'entity-first') { -%>
|
|
15
|
-
import { <%= camelName %>Collection } from './collection';
|
|
16
|
-
import type { <%= className %> } from './types';
|
|
17
|
-
<% } else if (generate.structure === 'concern-first') { -%>
|
|
18
|
-
import { <%= camelName %>Collection } from '../collections/<%= name %>';
|
|
19
|
-
import type { <%= className %> } from '../types/<%= name %>';
|
|
20
|
-
<% } -%>
|
|
21
|
-
|
|
22
|
-
export function insert<%= className %>(data: Omit<<%= className %>, 'id'<% if (hasTimestamps) { %> | 'createdAt' | 'updatedAt'<% } %>>) {
|
|
23
|
-
return <%= camelName %>Collection.insert({
|
|
24
|
-
id: crypto.randomUUID(),
|
|
25
|
-
<% if (hasTimestamps) { -%>
|
|
26
|
-
createdAt: new Date(),
|
|
27
|
-
updatedAt: new Date(),
|
|
28
|
-
<% } -%>
|
|
29
|
-
...data,
|
|
30
|
-
} as <%= className %>);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function update<%= className %>(id: string, fn: (draft: <%= className %>) => void) {
|
|
34
|
-
return <%= camelName %>Collection.update(id, fn);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function delete<%= className %>(id: string) {
|
|
38
|
-
return <%= camelName %>Collection.delete(id);
|
|
39
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= generate.structure === 'entity-first' ? `${locations.frontendGenerated.path}/${generate.fileNaming === 'plural' ? plural : name}/types.ts` : generate.structure === 'concern-first' ? `${locations.frontendGenerated.path}/types/${generate.fileNaming === 'plural' ? plural : name}.ts` : '' %>"
|
|
3
|
-
skip_if: <%= !frontendEnabled || (generate.structure === 'monolithic') %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> Types
|
|
9
|
-
* Generated by entity codegen - do not edit directly
|
|
10
|
-
*
|
|
11
|
-
* Type definitions for <%= className %> entity with resolved relations
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
<%
|
|
15
|
-
// Type import: depends on typeNaming config
|
|
16
|
-
// 'entity' = source exports OpportunityEntity, 'plain' = source exports Opportunity
|
|
17
|
-
const importedTypeName = generate.typeNaming === 'plain' ? className : className + 'Entity';
|
|
18
|
-
// Collect unique belongs_to targets for imports (FK resolution)
|
|
19
|
-
// Only import if fkResolution is enabled (default: true)
|
|
20
|
-
const importedEntities = new Set();
|
|
21
|
-
if (generate.fkResolution !== false) {
|
|
22
|
-
existingBelongsTo.forEach((rel) => {
|
|
23
|
-
if (rel.target !== name) {
|
|
24
|
-
importedEntities.add(rel.target);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
-%>
|
|
29
|
-
import type { <%= importedTypeName %> } from '<%= locations.dbEntities.import %><% if (!locations.dbEntities.barrelExport) { %>/<%= name %><% } %>';
|
|
30
|
-
<% if (importedEntities.size > 0) { -%>
|
|
31
|
-
|
|
32
|
-
// Import related entity types for FK resolution
|
|
33
|
-
<% importedEntities.forEach((target) => {
|
|
34
|
-
const targetClass = target.charAt(0).toUpperCase() + target.slice(1).replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
35
|
-
-%>
|
|
36
|
-
import type { <%= generate.typeNaming === 'plain' ? targetClass : targetClass + 'Entity' %> } from '<%= locations.dbEntities.import %><% if (!locations.dbEntities.barrelExport) { %>/<%= target %><% } %>';
|
|
37
|
-
<% }); -%>
|
|
38
|
-
<% } -%>
|
|
39
|
-
|
|
40
|
-
/** Base entity from database */
|
|
41
|
-
<% if (generate.typeNaming === 'plain') { -%>
|
|
42
|
-
export type { <%= className %> };
|
|
43
|
-
<% } else { -%>
|
|
44
|
-
export type <%= className %> = <%= importedTypeName %>;
|
|
45
|
-
<% } -%>
|
|
46
|
-
<% if (existingBelongsTo.length > 0 && generate.fkResolution !== false) { -%>
|
|
47
|
-
|
|
48
|
-
/** Entity with resolved FK relations (only includes relations with existing targets) */
|
|
49
|
-
export interface <%= className %>Resolved extends <%= className %> {
|
|
50
|
-
<% existingBelongsTo.forEach((rel) => { -%>
|
|
51
|
-
<% // Use local type for self-referential, imported type for others -%>
|
|
52
|
-
<% const relTypeName = rel.target === name ? className : (generate.typeNaming === 'plain' ? rel.targetClass : rel.targetClass + 'Entity'); -%>
|
|
53
|
-
<%= rel.name %>?: <%= relTypeName %>;
|
|
54
|
-
<% }); -%>
|
|
55
|
-
}
|
|
56
|
-
<% } else { -%>
|
|
57
|
-
|
|
58
|
-
/** Entity type (no FK relations to resolve) */
|
|
59
|
-
export type <%= className %>Resolved = <%= className %>;
|
|
60
|
-
<% } -%>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "// Collection imports"
|
|
5
|
-
skip_if: "from '<%= locations.frontendCollections.import %>/collections'"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
import { <%= collectionVarName %> } from '<%= locations.frontendCollections.import %>/collections';
|
|
9
|
-
<% } -%>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "collections: \\{"
|
|
5
|
-
skip_if: "<%= plural %>: <%= collectionVarName %>[^\\.]"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
<%= plural %>: <%= collectionVarName %>,
|
|
9
|
-
<% } -%>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "entities: \\{"
|
|
5
|
-
skip_if: "<%= plural %>: <%= camelName %>Hooks"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
<%= plural %>: <%= camelName %>Hooks,
|
|
9
|
-
<% } -%>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "// Entity hooks"
|
|
5
|
-
skip_if: "from './entities/<%= name %>'"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
import { <%= camelName %>Hooks } from './entities/<%= name %>';
|
|
9
|
-
<% } -%>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "// Lookup entries"
|
|
5
|
-
skip_if: "<%= plural %>: <%= collectionVarName %>\\.state"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
<%= plural %>: <%= collectionVarName %>.state,
|
|
9
|
-
<% } -%>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: "<%= frontendEnabled ? (generate.hooks ? `${locations.frontendStore.path}/index.ts` : '') : '' %>"
|
|
3
|
-
inject: true
|
|
4
|
-
after: "resolve: \\{"
|
|
5
|
-
skip_if: "<%= singularCamelName %>:"
|
|
6
|
-
---
|
|
7
|
-
<% if (generate.hooks) { -%>
|
|
8
|
-
<%= singularCamelName %>: (id: string | null | undefined) =>
|
|
9
|
-
id ? <%= collectionVarName %>.get(id) : undefined,
|
|
10
|
-
<% } -%>
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= locations.frontendStoreEntities.path %>/<%= name %>.ts
|
|
3
|
-
skip_if: <%= !frontendEnabled || (!generate.hooks) %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> Entity Hooks
|
|
9
|
-
* Generated by entity codegen - do not edit directly
|
|
10
|
-
*
|
|
11
|
-
* Provides query and mutation hooks for <%= className %> entity.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { useLiveQuery } from '@tanstack/react-db';
|
|
15
|
-
import { eq } from '@tanstack/react-db';
|
|
16
|
-
import { <%= camelName %>Collection } from '<%= locations.frontendCollections.import %>/collections';
|
|
17
|
-
<%
|
|
18
|
-
const entityTypeName = generate.typeNaming === 'plain' ? className : className + 'Entity';
|
|
19
|
-
-%>
|
|
20
|
-
import type { <%= entityTypeName %> } from '<%= locations.dbEntities.import %>/<%= name %>';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Hook to get all <%= plural %>
|
|
24
|
-
*/
|
|
25
|
-
export function use<%= className %>List() {
|
|
26
|
-
return useLiveQuery((q) => q.from({ <%= camelName %>Collection }), []);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Hook to get a single <%= camelName %> by ID
|
|
31
|
-
*/
|
|
32
|
-
export function use<%= className %>ById(id: string | undefined) {
|
|
33
|
-
return useLiveQuery(
|
|
34
|
-
(q) => {
|
|
35
|
-
if (!id) return undefined;
|
|
36
|
-
return q
|
|
37
|
-
.from({ <%= camelName %>Collection })
|
|
38
|
-
.where(({ <%= camelName %>Collection }) => eq(<%= camelName %>Collection.id, id));
|
|
39
|
-
},
|
|
40
|
-
[id],
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Mutation functions for <%= className %>
|
|
46
|
-
*/
|
|
47
|
-
export const <%= camelName %>Mutations = {
|
|
48
|
-
insert: (data: Omit<<%= entityTypeName %>, 'id' | 'createdAt' | 'updatedAt'> & { id?: string }) => {
|
|
49
|
-
return <%= camelName %>Collection.insert({
|
|
50
|
-
id: data.id ?? crypto.randomUUID(),
|
|
51
|
-
...data,
|
|
52
|
-
createdAt: new Date(),
|
|
53
|
-
updatedAt: new Date(),
|
|
54
|
-
} as <%= entityTypeName %>);
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
update: (id: string, updater: (draft: <%= entityTypeName %>) => void) => {
|
|
58
|
-
return <%= camelName %>Collection.update(id, updater);
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
delete: (id: string) => {
|
|
62
|
-
return <%= camelName %>Collection.delete(id);
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* <%= className %> hooks bundle for store
|
|
68
|
-
*/
|
|
69
|
-
export const <%= camelName %>Hooks = {
|
|
70
|
-
useList: use<%= className %>List,
|
|
71
|
-
useById: use<%= className %>ById,
|
|
72
|
-
...<%=camelName %>Mutations,
|
|
73
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= locations.frontendEntities.path %>/<%= name %>.ts
|
|
3
|
-
skip_if: <%= !frontendEnabled %>
|
|
4
|
-
force: true
|
|
5
|
-
---
|
|
6
|
-
<%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
|
|
7
|
-
/**
|
|
8
|
-
* <%= className %> - Unified Entity API
|
|
9
|
-
*
|
|
10
|
-
* AUTO-GENERATED by entity codegen - do not edit directly.
|
|
11
|
-
* Combines hooks, metadata, and collection into single interface.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { createUnifiedEntity } from './create-unified-entity';
|
|
15
|
-
import { <%= camelName %>Hooks } from '../store/entities/<%= name %>';
|
|
16
|
-
import { <%= camelName %>Metadata } from '<%= locations.frontendEntityMetadata.import %>';
|
|
17
|
-
import { <%= camelName %>Collection } from '<%= locations.frontendCollections.import %>/collections';
|
|
18
|
-
import { store } from '../store';
|
|
19
|
-
<%
|
|
20
|
-
const entityTypeName = generate.typeNaming === 'plain' ? className : className + 'Entity';
|
|
21
|
-
-%>
|
|
22
|
-
import type { <%= entityTypeName %> } from '<%= locations.dbEntities.import %>/<%= name %>';
|
|
23
|
-
|
|
24
|
-
export const <%= plural %> = createUnifiedEntity<<%= entityTypeName %>>({
|
|
25
|
-
hooks: <%= camelName %>Hooks,
|
|
26
|
-
metadata: <%= camelName %>Metadata,
|
|
27
|
-
collection: <%= camelName %>Collection,
|
|
28
|
-
resolve: store.resolve.<%= camelName %>,
|
|
29
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|