fetchium 0.1.1 → 0.2.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/development/QueryAdapter-DUo338ga.js +2 -0
  4. package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -0
  5. package/dist/cjs/development/QueryClient-vYETX2J2.js +2 -0
  6. package/dist/cjs/development/QueryClient-vYETX2J2.js.map +1 -0
  7. package/dist/cjs/development/index.js +1 -1
  8. package/dist/cjs/development/mutation-Beh3eks8.js +2 -0
  9. package/dist/cjs/development/mutation-Beh3eks8.js.map +1 -0
  10. package/dist/cjs/development/react/index.js +1 -1
  11. package/dist/cjs/development/rest/index.js +1 -1
  12. package/dist/cjs/development/rest/index.js.map +1 -1
  13. package/dist/cjs/development/topic/index.js +1 -1
  14. package/dist/cjs/development/topic/index.js.map +1 -1
  15. package/dist/cjs/production/QueryAdapter-DUo338ga.js +2 -0
  16. package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -0
  17. package/dist/cjs/production/QueryClient-DJoA1ac6.js +2 -0
  18. package/dist/cjs/production/QueryClient-DJoA1ac6.js.map +1 -0
  19. package/dist/cjs/production/index.js +1 -1
  20. package/dist/cjs/production/mutation-BnIsaYdm.js +2 -0
  21. package/dist/cjs/production/mutation-BnIsaYdm.js.map +1 -0
  22. package/dist/cjs/production/react/index.js +1 -1
  23. package/dist/cjs/production/rest/index.js +1 -1
  24. package/dist/cjs/production/rest/index.js.map +1 -1
  25. package/dist/cjs/production/topic/index.js +1 -1
  26. package/dist/cjs/production/topic/index.js.map +1 -1
  27. package/dist/esm/{QueryController.d.ts → QueryAdapter.d.ts} +7 -7
  28. package/dist/esm/QueryAdapter.d.ts.map +1 -0
  29. package/dist/esm/QueryClient.d.ts +6 -6
  30. package/dist/esm/QueryClient.d.ts.map +1 -1
  31. package/dist/esm/QueryResult.d.ts +2 -2
  32. package/dist/esm/QueryResult.d.ts.map +1 -1
  33. package/dist/esm/development/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
  34. package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -0
  35. package/dist/esm/development/{QueryClient-Dtde3pss.js → QueryClient-zAD_O9xj.js} +487 -479
  36. package/dist/esm/development/QueryClient-zAD_O9xj.js.map +1 -0
  37. package/dist/esm/development/index.js +14 -14
  38. package/dist/esm/development/{mutation-UZshUQAf.js → mutation-lw06SxbJ.js} +13 -13
  39. package/dist/esm/development/mutation-lw06SxbJ.js.map +1 -0
  40. package/dist/esm/development/react/index.js +1 -1
  41. package/dist/esm/development/rest/index.js +26 -26
  42. package/dist/esm/development/rest/index.js.map +1 -1
  43. package/dist/esm/development/topic/index.js +11 -11
  44. package/dist/esm/development/topic/index.js.map +1 -1
  45. package/dist/esm/index.d.ts +2 -2
  46. package/dist/esm/index.d.ts.map +1 -1
  47. package/dist/esm/mutation.d.ts +3 -3
  48. package/dist/esm/mutation.d.ts.map +1 -1
  49. package/dist/esm/production/{QueryController-Ch_ncxiI.js → QueryAdapter-Bu5UJjE4.js} +2 -2
  50. package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -0
  51. package/dist/esm/production/{QueryClient-YqnBxFy1.js → QueryClient-DSAzqTG6.js} +983 -975
  52. package/dist/esm/production/QueryClient-DSAzqTG6.js.map +1 -0
  53. package/dist/esm/production/index.js +14 -14
  54. package/dist/esm/production/{mutation-pgFl1uIY.js → mutation-Dmb9k9FG.js} +13 -13
  55. package/dist/esm/production/mutation-Dmb9k9FG.js.map +1 -0
  56. package/dist/esm/production/react/index.js +1 -1
  57. package/dist/esm/production/rest/index.js +26 -26
  58. package/dist/esm/production/rest/index.js.map +1 -1
  59. package/dist/esm/production/topic/index.js +11 -11
  60. package/dist/esm/production/topic/index.js.map +1 -1
  61. package/dist/esm/query.d.ts +6 -6
  62. package/dist/esm/query.d.ts.map +1 -1
  63. package/dist/esm/rest/RESTMutation.d.ts +2 -2
  64. package/dist/esm/rest/RESTMutation.d.ts.map +1 -1
  65. package/dist/esm/rest/RESTQuery.d.ts +2 -2
  66. package/dist/esm/rest/RESTQuery.d.ts.map +1 -1
  67. package/dist/esm/rest/{RESTQueryController.d.ts → RESTQueryAdapter.d.ts} +6 -6
  68. package/dist/esm/rest/RESTQueryAdapter.d.ts.map +1 -0
  69. package/dist/esm/rest/index.d.ts +2 -2
  70. package/dist/esm/rest/index.d.ts.map +1 -1
  71. package/dist/esm/retry.d.ts.map +1 -1
  72. package/dist/esm/topic/TopicQuery.d.ts +2 -2
  73. package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
  74. package/dist/esm/topic/{TopicQueryController.d.ts → TopicQueryAdapter.d.ts} +3 -3
  75. package/dist/esm/topic/TopicQueryAdapter.d.ts.map +1 -0
  76. package/dist/esm/topic/index.d.ts +1 -1
  77. package/dist/esm/topic/index.d.ts.map +1 -1
  78. package/package.json +1 -1
  79. package/plugin/docs/api/fetchium.md +40 -40
  80. package/plugin/docs/core/queries.md +15 -15
  81. package/plugin/docs/core/streaming.md +18 -18
  82. package/plugin/docs/data/mutations.md +5 -5
  83. package/plugin/docs/quickstart.md +1 -1
  84. package/plugin/docs/setup/project-setup.md +19 -19
  85. package/dist/cjs/development/QueryClient-CLi3ONNM.js +0 -2
  86. package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +0 -1
  87. package/dist/cjs/development/QueryController-BQA49OYU.js +0 -2
  88. package/dist/cjs/development/QueryController-BQA49OYU.js.map +0 -1
  89. package/dist/cjs/development/mutation-CikIl_6k.js +0 -2
  90. package/dist/cjs/development/mutation-CikIl_6k.js.map +0 -1
  91. package/dist/cjs/production/QueryClient-N0MJmuHW.js +0 -2
  92. package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +0 -1
  93. package/dist/cjs/production/QueryController-BQA49OYU.js +0 -2
  94. package/dist/cjs/production/QueryController-BQA49OYU.js.map +0 -1
  95. package/dist/cjs/production/mutation-P_Yb4LI9.js +0 -2
  96. package/dist/cjs/production/mutation-P_Yb4LI9.js.map +0 -1
  97. package/dist/esm/QueryController.d.ts.map +0 -1
  98. package/dist/esm/development/QueryClient-Dtde3pss.js.map +0 -1
  99. package/dist/esm/development/QueryController-Ch_ncxiI.js.map +0 -1
  100. package/dist/esm/development/mutation-UZshUQAf.js.map +0 -1
  101. package/dist/esm/production/QueryClient-YqnBxFy1.js.map +0 -1
  102. package/dist/esm/production/QueryController-Ch_ncxiI.js.map +0 -1
  103. package/dist/esm/production/mutation-pgFl1uIY.js.map +0 -1
  104. package/dist/esm/rest/RESTQueryController.d.ts.map +0 -1
  105. package/dist/esm/topic/TopicQueryController.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryController-Ch_ncxiI.js","sources":["../../../src/QueryController.ts"],"sourcesContent":["import { type QueryContext } from './query-types.js';\nimport type { Query } from './query.js';\nimport type { Mutation } from './mutation.js';\n\n// ================================\n// IQueryClient — minimal interface QueryController needs from the client\n// (avoids circular import: QueryClient → QueryController → QueryClient)\n// ================================\n\nexport interface IQueryClientForController {\n getContext(): QueryContext;\n applyMutationEvent(event: import('./types.js').MutationEvent): void;\n}\n\n// ================================\n// QueryController base class\n// ================================\n\nexport abstract class QueryController {\n protected queryClient: IQueryClientForController | undefined;\n\n /**\n * Called once by QueryClient when this controller is registered.\n * Subclasses can override to do setup (e.g. open a WebSocket connection).\n */\n register(queryClient: IQueryClientForController): void {\n this.queryClient = queryClient;\n }\n\n /**\n * Called when the network comes online or goes offline.\n * Subclasses can override to reconnect persistent connections (e.g. WebSocket).\n */\n onNetworkStatusChange?(isOnline: boolean): void;\n\n /**\n * Called when the QueryClient is destroyed.\n * Subclasses can override to clean up connections or timers.\n */\n destroy?(): void;\n\n /**\n * Send the query and return the raw response data.\n * @param ctx The query execution context (a reified Query instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n abstract send(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Fetch the next page of results. Only implement if the controller supports pagination.\n * @param ctx The query execution context. `ctx.resultData` contains the current page's data.\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendNext?(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Return true if more pages are available for the current result.\n * Called reactively — do not perform async work here.\n */\n hasNext?(ctx: Query): boolean;\n\n /**\n * Send a mutation and return the raw response data.\n * @param ctx The mutation execution context (a reified Mutation instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendMutation?(ctx: Mutation, signal: AbortSignal): Promise<unknown>;\n}\n"],"names":["QueryController","queryClient"],"mappings":"AAkBO,MAAeA,EAAgB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMV,SAASC,GAA8C;AACrD,SAAK,cAAcA;AAAA,EACrB;AAwCF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mutation-UZshUQAf.js","sources":["../../../src/mutation.ts"],"sourcesContent":["import { getContext, ReactiveTask } from 'signalium';\nimport { ExtractType, InternalTypeDef, MutationEffects, TypeDef, RetryConfig, TypeDefShape } from './types.js';\nimport { QueryClientContext, type QueryContext } from './QueryClient.js';\nimport { ValidatorDef, t } from './typeDefs.js';\nimport { createDefinitionProxy, extractDefinition, type CapturedDefinition } from './fieldRef.js';\nimport type { QueryController } from './QueryController.js';\n\n// ================================\n// Mutation Definition Types\n// ================================\n\nexport interface MutationConfigOptions {\n retry?: RetryConfig | number | false;\n}\n\nexport interface MutationDefinition<Request, Response> {\n id: string;\n requestShape: InternalTypeDef;\n responseShape: InternalTypeDef | undefined;\n captured: CapturedDefinition<Mutation>;\n optimisticUpdates: boolean;\n config?: MutationConfigOptions;\n effects?: MutationEffects;\n hasGetEffects: boolean;\n controllerClass: typeof QueryController;\n}\n\n// ================================\n// Mutation base class\n// ================================\n\nexport abstract class Mutation {\n static controller?: typeof QueryController;\n\n readonly params?: TypeDefShape;\n readonly result?: TypeDefShape;\n readonly optimisticUpdates?: boolean;\n readonly config?: MutationConfigOptions;\n readonly effects?: Readonly<MutationEffects>;\n\n declare context: QueryContext;\n\n abstract getIdentityKey(): unknown;\n\n getEffects?(): MutationEffects;\n\n constructor() {\n return createDefinitionProxy(this);\n }\n}\n\n// ================================\n// Mutation definition cache and lookup\n// ================================\n\nconst mutationDefCache = new WeakMap<new () => Mutation, () => MutationDefinition<any, any>>();\n\nexport const mutationKeyForClass = (cls: new () => Mutation): string => {\n const getMutationDef = mutationDefCache.get(cls);\n\n if (getMutationDef === undefined) {\n throw new Error('Mutation definition not found');\n }\n\n return getMutationDef().id;\n};\n\n// ================================\n// Internal: build mutation definition from class\n// ================================\n\nfunction buildMutationDefinition(MutationClass: new () => Mutation): () => MutationDefinition<any, any> {\n let cached = mutationDefCache.get(MutationClass);\n\n if (cached !== undefined) {\n return cached;\n }\n\n let mutationDefinition: MutationDefinition<any, any> | undefined;\n\n const getter = (): MutationDefinition<any, any> => {\n if (mutationDefinition !== undefined) {\n return mutationDefinition;\n }\n\n const instance = new MutationClass();\n const captured = extractDefinition(instance);\n const { fields } = captured;\n\n const id = `mutation:${String(captured.methods.getIdentityKey.call(fields))}`;\n\n const requestDef = fields.params ?? {};\n const requestShape = (requestDef instanceof ValidatorDef\n ? requestDef\n : t.object(requestDef)) as unknown as InternalTypeDef;\n const responseDef = fields.result;\n const responseShape =\n responseDef !== undefined\n ? ((responseDef instanceof ValidatorDef ? responseDef : t.object(responseDef)) as unknown as InternalTypeDef)\n : undefined;\n\n const controllerClass = (MutationClass as typeof Mutation).controller;\n if (!controllerClass) {\n throw new Error(\n `Mutation class \"${MutationClass.name}\" must define a static \\`controller\\` property. ` +\n `Extend RESTMutation (from fetchium/rest) or set \\`static controller = MyController\\` on your mutation class.`,\n );\n }\n\n mutationDefinition = {\n id,\n requestShape,\n responseShape,\n captured,\n optimisticUpdates: fields.optimisticUpdates ?? false,\n config: fields.config,\n effects: fields.effects,\n hasGetEffects: typeof captured.methods.getEffects === 'function',\n controllerClass,\n };\n\n return mutationDefinition;\n };\n\n mutationDefCache.set(MutationClass, getter);\n return getter;\n}\n\n// ================================\n// Public API\n// ================================\n\nexport function getMutation<T extends Mutation>(\n MutationClass: new () => T,\n): ReactiveTask<Readonly<ExtractType<T['result']>>, [ExtractType<T['params']>]> {\n const getMutationDef = buildMutationDefinition(MutationClass);\n\n const queryClient = getContext(QueryClientContext);\n\n if (queryClient === undefined) {\n throw new Error('QueryClient not found');\n }\n\n return queryClient.getMutation<any, any>(getMutationDef());\n}\n"],"names":["Mutation","createDefinitionProxy","mutationDefCache","mutationKeyForClass","cls","getMutationDef","buildMutationDefinition","MutationClass","cached","mutationDefinition","getter","instance","captured","extractDefinition","fields","id","requestDef","requestShape","ValidatorDef","t","responseDef","responseShape","controllerClass","getMutation","queryClient","getContext","QueryClientContext"],"mappings":";;AA+BO,MAAeA,EAAS;AAAA,EAC7B,OAAO;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAQT,cAAc;AACZ,WAAOC,EAAsB,IAAI;AAAA,EACnC;AACF;AAMA,MAAMC,wBAAuB,QAAA,GAEhBC,IAAsB,CAACC,MAAoC;AACtE,QAAMC,IAAiBH,EAAiB,IAAIE,CAAG;AAE/C,MAAIC,MAAmB;AACrB,UAAM,IAAI,MAAM,+BAA+B;AAGjD,SAAOA,IAAiB;AAC1B;AAMA,SAASC,EAAwBC,GAAuE;AACtG,MAAIC,IAASN,EAAiB,IAAIK,CAAa;AAE/C,MAAIC,MAAW;AACb,WAAOA;AAGT,MAAIC;AAEJ,QAAMC,IAAS,MAAoC;AACjD,QAAID,MAAuB;AACzB,aAAOA;AAGT,UAAME,IAAW,IAAIJ,EAAA,GACfK,IAAWC,EAAkBF,CAAQ,GACrC,EAAE,QAAAG,MAAWF,GAEbG,IAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,IAErEE,IAAaF,EAAO,UAAU,CAAA,GAC9BG,IAAgBD,aAAsBE,IACxCF,IACAG,EAAE,OAAOH,CAAU,GACjBI,IAAcN,EAAO,QACrBO,IACJD,MAAgB,SACVA,aAAuBF,IAAeE,IAAcD,EAAE,OAAOC,CAAW,IAC1E,QAEAE,IAAmBf,EAAkC;AAC3D,QAAI,CAACe;AACH,YAAM,IAAI;AAAA,QACR,mBAAmBf,EAAc,IAAI;AAAA,MAAA;AAKzC,WAAAE,IAAqB;AAAA,MACnB,IAAAM;AAAA,MACA,cAAAE;AAAA,MACA,eAAAI;AAAA,MACA,UAAAT;AAAA,MACA,mBAAmBE,EAAO,qBAAqB;AAAA,MAC/C,QAAQA,EAAO;AAAA,MACf,SAASA,EAAO;AAAA,MAChB,eAAe,OAAOF,EAAS,QAAQ,cAAe;AAAA,MACtD,iBAAAU;AAAA,IAAA,GAGKb;AAAA,EACT;AAEA,SAAAP,EAAiB,IAAIK,GAAeG,CAAM,GACnCA;AACT;AAMO,SAASa,EACdhB,GAC8E;AAC9E,QAAMF,IAAiBC,EAAwBC,CAAa,GAEtDiB,IAAcC,EAAWC,CAAkB;AAEjD,MAAIF,MAAgB;AAClB,UAAM,IAAI,MAAM,uBAAuB;AAGzC,SAAOA,EAAY,YAAsBnB,GAAgB;AAC3D;"}