aeria-sdk 0.0.24 → 0.0.26

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/dist/mirror.js CHANGED
@@ -17,7 +17,7 @@ const mirrorDts = (mirrorObj) => {
17
17
  SchemaWithId,
18
18
  MakeEndpoint,
19
19
  RequestMethod,
20
- CollectionFunctions
20
+ CollectionFunctionsPaginated
21
21
 
22
22
  } from '@aeriajs/types'
23
23
 
@@ -40,41 +40,50 @@ declare module 'aeria-sdk' {
40
40
  ? R
41
41
  : never
42
42
 
43
- type Endpoints = {
44
- [Route in keyof MirrorRouter]: {
45
- [Method in keyof MirrorRouter[Route]]: Method extends RequestMethod
46
- ? MirrorRouter[Route][Method] extends infer Contract
47
- ? Contract extends
48
- | { response: infer RouteResponse }
49
- | { payload: infer RoutePayload }
50
- | { query: infer RoutePayload }
51
- ? MakeEndpoint<Route, Method, InferResponse<RouteResponse>, InferProperty<RoutePayload>>
52
- : MakeEndpoint<Route, Method>
53
- : never
43
+ type InferEndpoint<Route extends keyof MirrorRouter> = {
44
+ [Method in keyof MirrorRouter[Route]]: Method extends RequestMethod
45
+ ? MirrorRouter[Route][Method] extends infer Contract
46
+ ? Contract extends
47
+ | { response: infer RouteResponse }
48
+ | { payload: infer RoutePayload }
49
+ | { query: infer RoutePayload }
50
+ ? MakeEndpoint<
51
+ Route,
52
+ Method,
53
+ InferResponse<RouteResponse>,
54
+ RoutePayload extends {}
55
+ ? InferProperty<RoutePayload>
56
+ : undefined
57
+ >
58
+ : MakeEndpoint<Route, Method>
54
59
  : never
60
+ : never
55
61
  } extends infer Methods
56
62
  ? Methods[keyof Methods]
57
63
  : never
64
+
65
+ type Endpoints = {
66
+ [Route in keyof MirrorRouter]: Route extends \`/\${infer Coll}/\${infer Fn}\`
67
+ ? Coll extends keyof Collections
68
+ ? Fn extends keyof CollectionFunctionsPaginated<any>
69
+ ? Record<Coll, Record<
70
+ Fn, {
71
+ POST: CollectionFunctionsPaginated<SchemaWithId<MirrorDescriptions[Coll]>>[Fn]
72
+ }
73
+ >>
74
+ : InferEndpoint<Route>
75
+ : InferEndpoint<Route>
76
+ : InferEndpoint<Route>
58
77
  } extends infer Endpoints
59
78
  ? UnionToIntersection<Endpoints[keyof Endpoints]>
60
79
  : never
61
80
 
62
- type StrongelyTypedTLO = TopLevelObject & Endpoints & {
63
- [K in keyof MirrorDescriptions]: SchemaWithId<MirrorDescriptions[K]> extends infer Document
64
- ? CollectionFunctions<Document> extends infer Functions
65
- ? Omit<TLOFunctions, keyof Functions> & {
66
- [P in keyof Functions]: {
67
- POST: Functions[P]
68
- }
69
- }
70
- : never
71
- : never
72
- }
81
+ type StrongelyTypedTLO = TopLevelObject & Endpoints
73
82
 
74
83
  export const url: string
75
84
  export const aeria: StrongelyTypedTLO
76
- }\n
77
- `;
85
+ }
86
+ \n`;
78
87
  };
79
88
  const runtimeCjs = (config) => `const config = ${JSON.stringify(config)}
80
89
  exports.config = config
package/dist/mirror.mjs CHANGED
@@ -129,7 +129,7 @@ import { topLevel } from "./topLevel.mjs";
129
129
  import { apiUrl } from "./utils.mjs";
130
130
  var mirrorDts = function(mirrorObj) {
131
131
  var collections = mirrorObj.descriptions;
132
- return "import type {\n InferProperty,\n InferResponse,\n SchemaWithId,\n MakeEndpoint,\n RequestMethod,\n CollectionFunctions\n\n} from '@aeriajs/types'\n\ndeclare type MirrorDescriptions = ".concat(JSON.stringify(collections, null, 2), "\n\n\ndeclare type MirrorRouter = ").concat(JSON.stringify(mirrorObj.router, null, 2), "\n\n\ndeclare global {\n type Collections = {\n [K in keyof MirrorDescriptions]: {\n item: SchemaWithId<MirrorDescriptions[K]>\n }\n }\n}\n\ndeclare module 'aeria-sdk' {\n import { TopLevelObject, TLOFunctions } from 'aeria-sdk'\n\n type UnionToIntersection<T> = (T extends any ? ((x: T) => 0) : never) extends ((x: infer R) => 0)\n ? R\n : never\n\n type Endpoints = {\n [Route in keyof MirrorRouter]: {\n [Method in keyof MirrorRouter[Route]]: Method extends RequestMethod\n ? MirrorRouter[Route][Method] extends infer Contract\n ? Contract extends\n | { response: infer RouteResponse }\n | { payload: infer RoutePayload }\n | { query: infer RoutePayload }\n ? MakeEndpoint<Route, Method, InferResponse<RouteResponse>, InferProperty<RoutePayload>>\n : MakeEndpoint<Route, Method>\n : never\n : never\n } extends infer Methods\n ? Methods[keyof Methods]\n : never\n } extends infer Endpoints\n ? UnionToIntersection<Endpoints[keyof Endpoints]>\n : never\n\n type StrongelyTypedTLO = TopLevelObject & Endpoints & {\n [K in keyof MirrorDescriptions]: SchemaWithId<MirrorDescriptions[K]> extends infer Document\n ? CollectionFunctions<Document> extends infer Functions\n ? Omit<TLOFunctions, keyof Functions> & {\n [P in keyof Functions]: {\n POST: Functions[P]\n }\n }\n : never\n : never\n }\n\n export const url: string\n export const aeria: StrongelyTypedTLO\n}\n\n ");
132
+ return "import type {\n InferProperty,\n InferResponse,\n SchemaWithId,\n MakeEndpoint,\n RequestMethod,\n CollectionFunctionsPaginated\n\n} from '@aeriajs/types'\n\ndeclare type MirrorDescriptions = ".concat(JSON.stringify(collections, null, 2), "\n\n\ndeclare type MirrorRouter = ").concat(JSON.stringify(mirrorObj.router, null, 2), "\n\n\ndeclare global {\n type Collections = {\n [K in keyof MirrorDescriptions]: {\n item: SchemaWithId<MirrorDescriptions[K]>\n }\n }\n}\n\ndeclare module 'aeria-sdk' {\n import { TopLevelObject, TLOFunctions } from 'aeria-sdk'\n\n type UnionToIntersection<T> = (T extends any ? ((x: T) => 0) : never) extends ((x: infer R) => 0)\n ? R\n : never\n\n type InferEndpoint<Route extends keyof MirrorRouter> = {\n [Method in keyof MirrorRouter[Route]]: Method extends RequestMethod\n ? MirrorRouter[Route][Method] extends infer Contract\n ? Contract extends\n | { response: infer RouteResponse }\n | { payload: infer RoutePayload }\n | { query: infer RoutePayload }\n ? MakeEndpoint<\n Route,\n Method,\n InferResponse<RouteResponse>,\n RoutePayload extends {}\n ? InferProperty<RoutePayload>\n : undefined\n >\n : MakeEndpoint<Route, Method>\n : never\n : never\n } extends infer Methods\n ? Methods[keyof Methods]\n : never\n\n type Endpoints = {\n [Route in keyof MirrorRouter]: Route extends `/${infer Coll}/${infer Fn}`\n ? Coll extends keyof Collections\n ? Fn extends keyof CollectionFunctionsPaginated<any>\n ? Record<Coll, Record<\n Fn, {\n POST: CollectionFunctionsPaginated<SchemaWithId<MirrorDescriptions[Coll]>>[Fn]\n }\n >>\n : InferEndpoint<Route>\n : InferEndpoint<Route>\n : InferEndpoint<Route>\n } extends infer Endpoints\n ? UnionToIntersection<Endpoints[keyof Endpoints]>\n : never\n\n type StrongelyTypedTLO = TopLevelObject & Endpoints\n\n export const url: string\n export const aeria: StrongelyTypedTLO\n}\n\n");
133
133
  };
134
134
  export var runtimeCjs = function(config) {
135
135
  return "const config = ".concat(JSON.stringify(config), "\nexports.config = config\nexports.url = '").concat(apiUrl(config), "'\nexports.aeria = require('aeria-sdk/topLevel').topLevel(config)\nexports.storage = require('aeria-sdk/storage').getStorage(config)\n\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aeria-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -49,8 +49,8 @@
49
49
  }
50
50
  },
51
51
  "peerDependencies": {
52
- "@aeriajs/common": "^0.0.5",
53
- "@aeriajs/types": "^0.0.4"
52
+ "@aeriajs/common": "^0.0.7",
53
+ "@aeriajs/types": "^0.0.6"
54
54
  },
55
55
  "scripts": {
56
56
  "test": "echo skipping",