@hazeljs/prompts 0.2.0-beta.64

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.
Files changed (66) hide show
  1. package/LICENSE +192 -0
  2. package/dist/__tests__/registry.test.d.ts +2 -0
  3. package/dist/__tests__/registry.test.d.ts.map +1 -0
  4. package/dist/__tests__/registry.test.js +255 -0
  5. package/dist/__tests__/registry.test.js.map +1 -0
  6. package/dist/__tests__/stores/file.store.test.d.ts +2 -0
  7. package/dist/__tests__/stores/file.store.test.d.ts.map +1 -0
  8. package/dist/__tests__/stores/file.store.test.js +134 -0
  9. package/dist/__tests__/stores/file.store.test.js.map +1 -0
  10. package/dist/__tests__/stores/memory.store.test.d.ts +2 -0
  11. package/dist/__tests__/stores/memory.store.test.d.ts.map +1 -0
  12. package/dist/__tests__/stores/memory.store.test.js +74 -0
  13. package/dist/__tests__/stores/memory.store.test.js.map +1 -0
  14. package/dist/__tests__/stores/multi.store.test.d.ts +2 -0
  15. package/dist/__tests__/stores/multi.store.test.d.ts.map +1 -0
  16. package/dist/__tests__/stores/multi.store.test.js +81 -0
  17. package/dist/__tests__/stores/multi.store.test.js.map +1 -0
  18. package/dist/__tests__/template.test.d.ts +2 -0
  19. package/dist/__tests__/template.test.d.ts.map +1 -0
  20. package/dist/__tests__/template.test.js +60 -0
  21. package/dist/__tests__/template.test.js.map +1 -0
  22. package/dist/index.d.ts +13 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +18 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/registry.d.ts +153 -0
  27. package/dist/registry.d.ts.map +1 -0
  28. package/dist/registry.js +288 -0
  29. package/dist/registry.js.map +1 -0
  30. package/dist/stores/database.store.d.ts +93 -0
  31. package/dist/stores/database.store.d.ts.map +1 -0
  32. package/dist/stores/database.store.js +46 -0
  33. package/dist/stores/database.store.js.map +1 -0
  34. package/dist/stores/file.store.d.ts +49 -0
  35. package/dist/stores/file.store.d.ts.map +1 -0
  36. package/dist/stores/file.store.js +105 -0
  37. package/dist/stores/file.store.js.map +1 -0
  38. package/dist/stores/index.d.ts +10 -0
  39. package/dist/stores/index.d.ts.map +1 -0
  40. package/dist/stores/index.js +14 -0
  41. package/dist/stores/index.js.map +1 -0
  42. package/dist/stores/memory.store.d.ts +21 -0
  43. package/dist/stores/memory.store.d.ts.map +1 -0
  44. package/dist/stores/memory.store.js +63 -0
  45. package/dist/stores/memory.store.js.map +1 -0
  46. package/dist/stores/multi.store.d.ts +44 -0
  47. package/dist/stores/multi.store.d.ts.map +1 -0
  48. package/dist/stores/multi.store.js +68 -0
  49. package/dist/stores/multi.store.js.map +1 -0
  50. package/dist/stores/redis.store.d.ts +65 -0
  51. package/dist/stores/redis.store.d.ts.map +1 -0
  52. package/dist/stores/redis.store.js +81 -0
  53. package/dist/stores/redis.store.js.map +1 -0
  54. package/dist/stores/store.interface.d.ts +62 -0
  55. package/dist/stores/store.interface.d.ts.map +1 -0
  56. package/dist/stores/store.interface.js +3 -0
  57. package/dist/stores/store.interface.js.map +1 -0
  58. package/dist/template.d.ts +38 -0
  59. package/dist/template.d.ts.map +1 -0
  60. package/dist/template.js +46 -0
  61. package/dist/template.js.map +1 -0
  62. package/dist/types.d.ts +15 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +3 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +74 -0
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const memory_store_1 = require("../../stores/memory.store");
4
+ function entry(key, version = '1.0.0', template = 'Hello {name}') {
5
+ return {
6
+ key,
7
+ version,
8
+ template,
9
+ metadata: { name: key, version },
10
+ storedAt: new Date().toISOString(),
11
+ };
12
+ }
13
+ describe('MemoryStore', () => {
14
+ let store;
15
+ beforeEach(() => {
16
+ store = new memory_store_1.MemoryStore();
17
+ });
18
+ it('has name "memory"', () => {
19
+ expect(store.name).toBe('memory');
20
+ });
21
+ it('set / get roundtrip', async () => {
22
+ await store.set(entry('a:key'));
23
+ const result = await store.get('a:key', '1.0.0');
24
+ expect(result?.template).toBe('Hello {name}');
25
+ });
26
+ it('get() defaults to latest', async () => {
27
+ await store.set(entry('a:key', '1.0.0'));
28
+ const latest = await store.get('a:key');
29
+ expect(latest?.version).toBe('latest');
30
+ });
31
+ it('get() returns undefined for missing key', async () => {
32
+ expect(await store.get('missing:key')).toBeUndefined();
33
+ });
34
+ it('has() returns true when entry exists', async () => {
35
+ await store.set(entry('b:key'));
36
+ expect(await store.has('b:key', '1.0.0')).toBe(true);
37
+ });
38
+ it('has() returns false when entry missing', async () => {
39
+ expect(await store.has('nope:key')).toBe(false);
40
+ });
41
+ it('delete() by version removes only that version', async () => {
42
+ await store.set(entry('c:key', '1.0.0'));
43
+ await store.set(entry('c:key', '2.0.0'));
44
+ await store.delete('c:key', '1.0.0');
45
+ expect(await store.has('c:key', '1.0.0')).toBe(false);
46
+ expect(await store.has('c:key', '2.0.0')).toBe(true);
47
+ });
48
+ it('delete() without version removes all versions', async () => {
49
+ await store.set(entry('d:key', '1.0.0'));
50
+ await store.set(entry('d:key', '2.0.0'));
51
+ await store.delete('d:key');
52
+ expect(await store.has('d:key')).toBe(false);
53
+ });
54
+ it('keys() returns unique keys', async () => {
55
+ await store.set(entry('k1', '1.0.0'));
56
+ await store.set(entry('k1', '2.0.0'));
57
+ await store.set(entry('k2'));
58
+ const keys = await store.keys();
59
+ expect(keys).toContain('k1');
60
+ expect(keys).toContain('k2');
61
+ // k1 appears only once despite multiple versions
62
+ expect(keys.filter((k) => k === 'k1')).toHaveLength(1);
63
+ });
64
+ it('versions() returns all non-latest versions sorted', async () => {
65
+ await store.set(entry('ver:key', '1.0.0'));
66
+ await store.set(entry('ver:key', '2.0.0'));
67
+ const vers = await store.versions('ver:key');
68
+ expect(vers).toEqual(['1.0.0', '2.0.0']);
69
+ });
70
+ it('versions() returns empty array for unknown key', async () => {
71
+ expect(await store.versions('unknown')).toEqual([]);
72
+ });
73
+ });
74
+ //# sourceMappingURL=memory.store.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.store.test.js","sourceRoot":"","sources":["../../../src/__tests__/stores/memory.store.test.ts"],"names":[],"mappings":";;AAAA,4DAAwD;AAGxD,SAAS,KAAK,CAAC,GAAW,EAAE,OAAO,GAAG,OAAO,EAAE,QAAQ,GAAG,cAAc;IACtE,OAAO;QACL,GAAG;QACH,OAAO;QACP,QAAQ;QACR,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,KAAkB,CAAC;IAEvB,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,GAAG,IAAI,0BAAW,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,KAAK,CAA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AAC,CAAC,CAAC;QAC3C,MAAM,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=multi.store.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi.store.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/stores/multi.store.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const multi_store_1 = require("../../stores/multi.store");
4
+ const memory_store_1 = require("../../stores/memory.store");
5
+ function entry(key, version = '1.0.0', template = 'Hi {x}') {
6
+ return {
7
+ key,
8
+ version,
9
+ template,
10
+ metadata: { name: key, version },
11
+ storedAt: new Date().toISOString(),
12
+ };
13
+ }
14
+ describe('MultiStore', () => {
15
+ it('name reflects inner store names', () => {
16
+ const multi = new multi_store_1.MultiStore([new memory_store_1.MemoryStore(), new memory_store_1.MemoryStore()]);
17
+ expect(multi.name).toContain('memory');
18
+ });
19
+ it('set() fans out to all stores', async () => {
20
+ const s1 = new memory_store_1.MemoryStore();
21
+ const s2 = new memory_store_1.MemoryStore();
22
+ const multi = new multi_store_1.MultiStore([s1, s2]);
23
+ await multi.set(entry('fan:key'));
24
+ expect(await s1.has('fan:key', '1.0.0')).toBe(true);
25
+ expect(await s2.has('fan:key', '1.0.0')).toBe(true);
26
+ });
27
+ it('get() returns from first store that has the entry', async () => {
28
+ const s1 = new memory_store_1.MemoryStore();
29
+ const s2 = new memory_store_1.MemoryStore();
30
+ await s2.set(entry('only:s2', '1.0.0', 'from s2'));
31
+ const multi = new multi_store_1.MultiStore([s1, s2]);
32
+ const result = await multi.get('only:s2', '1.0.0');
33
+ expect(result?.template).toBe('from s2');
34
+ });
35
+ it('get() returns undefined when none have the entry', async () => {
36
+ const multi = new multi_store_1.MultiStore([new memory_store_1.MemoryStore()]);
37
+ expect(await multi.get('missing:key')).toBeUndefined();
38
+ });
39
+ it('has() returns true if any store has the entry', async () => {
40
+ const s1 = new memory_store_1.MemoryStore();
41
+ const s2 = new memory_store_1.MemoryStore();
42
+ await s2.set(entry('has:s2'));
43
+ const multi = new multi_store_1.MultiStore([s1, s2]);
44
+ expect(await multi.has('has:s2', '1.0.0')).toBe(true);
45
+ });
46
+ it('has() returns false if no store has the entry', async () => {
47
+ const multi = new multi_store_1.MultiStore([new memory_store_1.MemoryStore()]);
48
+ expect(await multi.has('nope')).toBe(false);
49
+ });
50
+ it('delete() removes from all stores', async () => {
51
+ const s1 = new memory_store_1.MemoryStore();
52
+ const s2 = new memory_store_1.MemoryStore();
53
+ await s1.set(entry('del:key'));
54
+ await s2.set(entry('del:key'));
55
+ const multi = new multi_store_1.MultiStore([s1, s2]);
56
+ await multi.delete('del:key', '1.0.0');
57
+ expect(await s1.has('del:key', '1.0.0')).toBe(false);
58
+ expect(await s2.has('del:key', '1.0.0')).toBe(false);
59
+ });
60
+ it('keys() returns union of keys across stores', async () => {
61
+ const s1 = new memory_store_1.MemoryStore();
62
+ const s2 = new memory_store_1.MemoryStore();
63
+ await s1.set(entry('k1'));
64
+ await s2.set(entry('k2'));
65
+ const multi = new multi_store_1.MultiStore([s1, s2]);
66
+ const keys = await multi.keys();
67
+ expect(keys).toContain('k1');
68
+ expect(keys).toContain('k2');
69
+ });
70
+ it('versions() returns union of versions across stores', async () => {
71
+ const s1 = new memory_store_1.MemoryStore();
72
+ const s2 = new memory_store_1.MemoryStore();
73
+ await s1.set(entry('vk', '1.0.0'));
74
+ await s2.set(entry('vk', '2.0.0'));
75
+ const multi = new multi_store_1.MultiStore([s1, s2]);
76
+ const vers = await multi.versions('vk');
77
+ expect(vers).toContain('1.0.0');
78
+ expect(vers).toContain('2.0.0');
79
+ });
80
+ });
81
+ //# sourceMappingURL=multi.store.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi.store.test.js","sourceRoot":"","sources":["../../../src/__tests__/stores/multi.store.test.ts"],"names":[],"mappings":";;AAAA,0DAAsD;AACtD,4DAAwD;AAGxD,SAAS,KAAK,CAAC,GAAW,EAAE,OAAO,GAAG,OAAO,EAAE,QAAQ,GAAG,QAAQ;IAChE,OAAO;QACL,GAAG;QACH,OAAO;QACP,QAAQ;QACR,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;QAChC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,CAAC,IAAI,0BAAW,EAAE,EAAE,IAAI,0BAAW,EAAE,CAAC,CAAC,CAAC;QACrE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,EAAE,GAAG,IAAI,0BAAW,EAAE,CAAC;QAC7B,MAAM,EAAE,GAAG,IAAI,0BAAW,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,CAAC,EAAE,EAAE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ChC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=template.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/template.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const template_1 = require("../template");
4
+ describe('PromptTemplate', () => {
5
+ describe('constructor', () => {
6
+ it('stores template string and metadata', () => {
7
+ const tpl = new template_1.PromptTemplate('Hello {name}', { name: 'Test', version: '1.0.0' });
8
+ expect(tpl.template).toBe('Hello {name}');
9
+ expect(tpl.metadata.name).toBe('Test');
10
+ expect(tpl.metadata.version).toBe('1.0.0');
11
+ });
12
+ });
13
+ describe('render()', () => {
14
+ it('substitutes a single variable', () => {
15
+ const tpl = new template_1.PromptTemplate('Hello {name}!', { name: 'Test' });
16
+ expect(tpl.render({ name: 'World' })).toBe('Hello World!');
17
+ });
18
+ it('substitutes multiple variables', () => {
19
+ const tpl = new template_1.PromptTemplate('Context: {context}\nQuestion: {query}', { name: 'QA' });
20
+ const rendered = tpl.render({ query: 'What?', context: 'Some context' });
21
+ expect(rendered).toBe('Context: Some context\nQuestion: What?');
22
+ });
23
+ it('leaves unrecognised placeholders intact', () => {
24
+ const tpl = new template_1.PromptTemplate('Hello {name} from {place}', {
25
+ name: 'Test',
26
+ });
27
+ expect(tpl.render({ name: 'Alice' })).toBe('Hello Alice from {place}');
28
+ });
29
+ it('converts non-string values to string', () => {
30
+ const tpl = new template_1.PromptTemplate('Count: {count}', { name: 'Counter' });
31
+ expect(tpl.render({ count: 42 })).toBe('Count: 42');
32
+ });
33
+ it('handles empty template', () => {
34
+ const tpl = new template_1.PromptTemplate('', { name: 'Empty' });
35
+ expect(tpl.render({})).toBe('');
36
+ });
37
+ it('handles template with no placeholders', () => {
38
+ const tpl = new template_1.PromptTemplate('Static text only.', {
39
+ name: 'Static',
40
+ });
41
+ expect(tpl.render({})).toBe('Static text only.');
42
+ });
43
+ it('substitutes the same placeholder multiple times', () => {
44
+ const tpl = new template_1.PromptTemplate('{word} and {word} again', { name: 'Rep' });
45
+ expect(tpl.render({ word: 'yes' })).toBe('yes and yes again');
46
+ });
47
+ it('handles multiline templates', () => {
48
+ const tpl = new template_1.PromptTemplate('Line 1: {a}\nLine 2: {b}\nDone.', {
49
+ name: 'ML',
50
+ });
51
+ const result = tpl.render({ a: 'foo', b: 'bar' });
52
+ expect(result).toBe('Line 1: foo\nLine 2: bar\nDone.');
53
+ });
54
+ it('handles undefined values by leaving placeholder', () => {
55
+ const tpl = new template_1.PromptTemplate('{defined} {optional}', { name: 'Partial' });
56
+ expect(tpl.render({ defined: 'hello' })).toBe('hello {optional}');
57
+ });
58
+ });
59
+ });
60
+ //# sourceMappingURL=template.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.test.js","sourceRoot":"","sources":["../../src/__tests__/template.test.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AAE7C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC7C,MAAM,GAAG,GAAG,IAAI,yBAAc,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACnF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC1C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CA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AI,CAAC,iCAAiC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACzD,MAAM,GAAG,GAAG,IAAI,yBAAc,CAC5B,sBAAsB,EACtB,EAAE,IAAI,EAAE,SAAS,EAAE,CACpB,CAAC;YACF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type { PromptMetadata } from './types';
2
+ export { PromptTemplate } from './template';
3
+ export { PromptRegistry } from './registry';
4
+ export type { PromptEntry, PromptStore } from './stores/store.interface';
5
+ export { MemoryStore } from './stores/memory.store';
6
+ export { FileStore } from './stores/file.store';
7
+ export type { FileStoreOptions } from './stores/file.store';
8
+ export { RedisStore } from './stores/redis.store';
9
+ export type { RedisAdapter, RedisStoreOptions } from './stores/redis.store';
10
+ export { DatabaseStore } from './stores/database.store';
11
+ export type { DatabaseAdapter, DatabaseStoreOptions } from './stores/database.store';
12
+ export { MultiStore } from './stores/multi.store';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultiStore = exports.DatabaseStore = exports.RedisStore = exports.FileStore = exports.MemoryStore = exports.PromptRegistry = exports.PromptTemplate = void 0;
4
+ var template_1 = require("./template");
5
+ Object.defineProperty(exports, "PromptTemplate", { enumerable: true, get: function () { return template_1.PromptTemplate; } });
6
+ var registry_1 = require("./registry");
7
+ Object.defineProperty(exports, "PromptRegistry", { enumerable: true, get: function () { return registry_1.PromptRegistry; } });
8
+ var memory_store_1 = require("./stores/memory.store");
9
+ Object.defineProperty(exports, "MemoryStore", { enumerable: true, get: function () { return memory_store_1.MemoryStore; } });
10
+ var file_store_1 = require("./stores/file.store");
11
+ Object.defineProperty(exports, "FileStore", { enumerable: true, get: function () { return file_store_1.FileStore; } });
12
+ var redis_store_1 = require("./stores/redis.store");
13
+ Object.defineProperty(exports, "RedisStore", { enumerable: true, get: function () { return redis_store_1.RedisStore; } });
14
+ var database_store_1 = require("./stores/database.store");
15
+ Object.defineProperty(exports, "DatabaseStore", { enumerable: true, get: function () { return database_store_1.DatabaseStore; } });
16
+ var multi_store_1 = require("./stores/multi.store");
17
+ Object.defineProperty(exports, "MultiStore", { enumerable: true, get: function () { return multi_store_1.MultiStore; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AAIvB,sDAAoD;AAA3C,2GAAA,WAAW,OAAA;AACpB,kDAAgD;AAAvC,uGAAA,SAAS,OAAA;AAElB,oDAAkD;AAAzC,yGAAA,UAAU,OAAA;AAEnB,0DAAwD;AAA/C,+GAAA,aAAa,OAAA;AAEtB,oDAAkD;AAAzC,yGAAA,UAAU,OAAA"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * PromptRegistry
3
+ *
4
+ * A global static store that maps string keys to PromptTemplate instances.
5
+ *
6
+ * ## Sync API (unchanged, zero-cost, works at module load time)
7
+ * Built-in prompt files self-register at import time via `register()`.
8
+ * Application code reads prompts synchronously via `get()`.
9
+ * End-users swap any prompt with `override()` at startup.
10
+ *
11
+ * ## Store backends (optional, async)
12
+ * One or more `PromptStore` implementations can be configured to
13
+ * persist/load prompts from the file system, Redis, a database, or any
14
+ * combination via `MultiStore`. The in-memory registry always acts as the
15
+ * runtime cache; stores are used for persistence and versioning.
16
+ *
17
+ * ## Versioning
18
+ * Every `PromptTemplate.metadata.version` is tracked in the version index.
19
+ * `get(key, version)` retrieves a specific cached version.
20
+ * `getAsync(key, version?)` falls back to configured stores when the version
21
+ * is not in the in-memory cache.
22
+ *
23
+ * Key naming convention: `package:scope:action`
24
+ * e.g. `rag:graph:entity-extraction`, `agent:supervisor:routing`
25
+ *
26
+ * @example Startup override
27
+ * ```typescript
28
+ * import { PromptRegistry, PromptTemplate } from '@hazeljs/prompts';
29
+ *
30
+ * PromptRegistry.override('rag:graph:entity-extraction', new PromptTemplate(
31
+ * 'Extract entities from: {text}',
32
+ * { name: 'Custom Extraction', version: '2.0.0' },
33
+ * ));
34
+ * ```
35
+ *
36
+ * @example Multiple store backends
37
+ * ```typescript
38
+ * import { PromptRegistry, FileStore, RedisStore, MultiStore } from '@hazeljs/prompts';
39
+ *
40
+ * PromptRegistry.configure([
41
+ * new MultiStore([
42
+ * new FileStore({ filePath: './prompts/library.json' }),
43
+ * new RedisStore({ client: redisClient }),
44
+ * ]),
45
+ * ]);
46
+ *
47
+ * await PromptRegistry.saveAll(); // persist current registry to all stores
48
+ * ```
49
+ */
50
+ import { PromptTemplate } from './template';
51
+ import type { PromptStore } from './stores/store.interface';
52
+ export declare class PromptRegistry {
53
+ /** Latest version for each key. */
54
+ private static readonly latest;
55
+ /**
56
+ * All cached versions per key.
57
+ * Shape: `{ [key]: { [version]: PromptTemplate } }`
58
+ */
59
+ private static readonly versioned;
60
+ private static stores;
61
+ /**
62
+ * Replace the configured store list.
63
+ * Called once at application startup before prompts are loaded.
64
+ */
65
+ static configure(stores: PromptStore[]): void;
66
+ /**
67
+ * Append a single store to the list without replacing existing ones.
68
+ */
69
+ static addStore(store: PromptStore): void;
70
+ /** Returns the names of all configured stores (useful for diagnostics). */
71
+ static storeNames(): string[];
72
+ /**
73
+ * Register a prompt only if the key has not already been registered.
74
+ * Built-in prompt files call this so they don't clobber user overrides
75
+ * set before the module is imported.
76
+ */
77
+ static register<T extends object>(key: string, template: PromptTemplate<T>): void;
78
+ /**
79
+ * Override an existing (or register a new) prompt unconditionally.
80
+ * This is the entry point for end-user customisation.
81
+ */
82
+ static override<T extends object>(key: string, template: PromptTemplate<T>): void;
83
+ /**
84
+ * Retrieve a registered prompt by key.
85
+ *
86
+ * @param key - Registry key (e.g. `rag:graph:entity-extraction`).
87
+ * @param version - Optional specific version. Defaults to `'latest'`.
88
+ * @throws When the key (or requested version) is not found in the cache.
89
+ */
90
+ static get<T extends object>(key: string, version?: string): PromptTemplate<T>;
91
+ /** Returns `true` when a prompt is registered under the given key. */
92
+ static has(key: string, version?: string): boolean;
93
+ /** Returns all registered prompt keys (latest versions) in insertion order. */
94
+ static list(): string[];
95
+ /**
96
+ * Returns all cached version strings for a given key (excludes `'latest'`).
97
+ * Returns an empty array when the key is not registered.
98
+ */
99
+ static versions(key: string): string[];
100
+ /**
101
+ * Remove a prompt from the cache.
102
+ * Primarily useful in tests to reset state between test cases.
103
+ * Pass `version` to remove only that version; omit to remove all versions.
104
+ */
105
+ static unregister(key: string, version?: string): void;
106
+ /**
107
+ * Clear every registered prompt from the in-memory cache.
108
+ * Does NOT affect configured stores.
109
+ * Useful in tests; not recommended in production.
110
+ */
111
+ static clear(): void;
112
+ /**
113
+ * Retrieve a prompt by key, checking the in-memory cache first.
114
+ * Falls back to configured stores when the version is not cached.
115
+ * The loaded template is added to the in-memory cache for subsequent calls.
116
+ *
117
+ * @param key - Registry key.
118
+ * @param version - Specific version string; defaults to `'latest'`.
119
+ * @throws When the key is not found in the cache or any configured store.
120
+ */
121
+ static getAsync<T extends object>(key: string, version?: string): Promise<PromptTemplate<T>>;
122
+ /**
123
+ * Persist the in-memory prompt for `key` to all configured stores.
124
+ * @param key - Registry key.
125
+ * @param version - Specific cached version to persist; defaults to `'latest'` (current).
126
+ */
127
+ static save(key: string, version?: string): Promise<void>;
128
+ /**
129
+ * Persist ALL in-memory prompts (latest version of each) to all configured stores.
130
+ */
131
+ static saveAll(): Promise<void>;
132
+ /**
133
+ * Load ALL prompts from the primary configured store into the in-memory cache.
134
+ * Existing in-memory registrations are NOT overwritten (same behaviour as `register()`).
135
+ * Use `override()` after `loadAll()` to force-replace specific keys.
136
+ *
137
+ * @param overwrite - When `true`, loaded entries overwrite existing cache entries.
138
+ * Default: `false`.
139
+ */
140
+ static loadAll(overwrite?: boolean): Promise<void>;
141
+ /**
142
+ * Load a single prompt (optionally a specific version) from the first
143
+ * store that has it, cache it, and return it.
144
+ *
145
+ * @param key - Registry key.
146
+ * @param version - Specific version string; defaults to `'latest'`.
147
+ */
148
+ static load(key: string, version?: string): Promise<PromptTemplate<object> | null>;
149
+ private static setInMemory;
150
+ private static templateToEntry;
151
+ private static entryToTemplate;
152
+ }
153
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AA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