@liminalfunctions/framework 1.0.11 → 1.0.12

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 (97) hide show
  1. package/dist/code_generation/utils/type_from_zod.js +2 -0
  2. package/dist/code_generation/utils/type_from_zod.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/code_generation/utils/type_from_zod.ts +2 -3
  5. package/test/2_0_client_library_basic_type_generation.test.ts +20 -0
  6. package/test/tmp/src/index.ts +1 -4
  7. package/test/tmp/src/types/test_collection.ts +3 -0
  8. package/test/tmp/src/types/test_collection_post.ts +3 -0
  9. package/test/tmp/src/types/test_collection_put.ts +3 -0
  10. package/test/tmp/src/types/test_collection_query.ts +6 -0
  11. package/test/tmp/dist/Brief_News_Category.d.ts +0 -16
  12. package/test/tmp/dist/Brief_News_Category.js +0 -85
  13. package/test/tmp/dist/Brief_News_Category.js.map +0 -1
  14. package/test/tmp/dist/Client.d.ts +0 -19
  15. package/test/tmp/dist/Client.js +0 -97
  16. package/test/tmp/dist/Client.js.map +0 -1
  17. package/test/tmp/dist/Institution.d.ts +0 -18
  18. package/test/tmp/dist/Institution.js +0 -94
  19. package/test/tmp/dist/Institution.js.map +0 -1
  20. package/test/tmp/dist/Project.d.ts +0 -16
  21. package/test/tmp/dist/Project.js +0 -85
  22. package/test/tmp/dist/Project.js.map +0 -1
  23. package/test/tmp/dist/index.d.ts +0 -4
  24. package/test/tmp/dist/index.js +0 -14
  25. package/test/tmp/dist/index.js.map +0 -1
  26. package/test/tmp/dist/types/brief_news_category.d.ts +0 -7
  27. package/test/tmp/dist/types/brief_news_category.js +0 -2
  28. package/test/tmp/dist/types/brief_news_category.js.map +0 -1
  29. package/test/tmp/dist/types/brief_news_category_post.d.ts +0 -7
  30. package/test/tmp/dist/types/brief_news_category_post.js +0 -2
  31. package/test/tmp/dist/types/brief_news_category_post.js.map +0 -1
  32. package/test/tmp/dist/types/brief_news_category_put.d.ts +0 -7
  33. package/test/tmp/dist/types/brief_news_category_put.js +0 -2
  34. package/test/tmp/dist/types/brief_news_category_put.js.map +0 -1
  35. package/test/tmp/dist/types/brief_news_category_query.d.ts +0 -26
  36. package/test/tmp/dist/types/brief_news_category_query.js +0 -2
  37. package/test/tmp/dist/types/brief_news_category_query.js.map +0 -1
  38. package/test/tmp/dist/types/client.d.ts +0 -5
  39. package/test/tmp/dist/types/client.js +0 -2
  40. package/test/tmp/dist/types/client.js.map +0 -1
  41. package/test/tmp/dist/types/client_post.d.ts +0 -5
  42. package/test/tmp/dist/types/client_post.js +0 -2
  43. package/test/tmp/dist/types/client_post.js.map +0 -1
  44. package/test/tmp/dist/types/client_put.d.ts +0 -5
  45. package/test/tmp/dist/types/client_put.js +0 -2
  46. package/test/tmp/dist/types/client_put.js.map +0 -1
  47. package/test/tmp/dist/types/client_query.d.ts +0 -18
  48. package/test/tmp/dist/types/client_query.js +0 -2
  49. package/test/tmp/dist/types/client_query.js.map +0 -1
  50. package/test/tmp/dist/types/institution.d.ts +0 -4
  51. package/test/tmp/dist/types/institution.js +0 -2
  52. package/test/tmp/dist/types/institution.js.map +0 -1
  53. package/test/tmp/dist/types/institution_post.d.ts +0 -4
  54. package/test/tmp/dist/types/institution_post.js +0 -2
  55. package/test/tmp/dist/types/institution_post.js.map +0 -1
  56. package/test/tmp/dist/types/institution_put.d.ts +0 -4
  57. package/test/tmp/dist/types/institution_put.js +0 -2
  58. package/test/tmp/dist/types/institution_put.js.map +0 -1
  59. package/test/tmp/dist/types/institution_query.d.ts +0 -14
  60. package/test/tmp/dist/types/institution_query.js +0 -2
  61. package/test/tmp/dist/types/institution_query.js.map +0 -1
  62. package/test/tmp/dist/types/project.d.ts +0 -7
  63. package/test/tmp/dist/types/project.js +0 -2
  64. package/test/tmp/dist/types/project.js.map +0 -1
  65. package/test/tmp/dist/types/project_post.d.ts +0 -7
  66. package/test/tmp/dist/types/project_post.js +0 -2
  67. package/test/tmp/dist/types/project_post.js.map +0 -1
  68. package/test/tmp/dist/types/project_put.d.ts +0 -7
  69. package/test/tmp/dist/types/project_put.js +0 -2
  70. package/test/tmp/dist/types/project_put.js.map +0 -1
  71. package/test/tmp/dist/types/project_query.d.ts +0 -27
  72. package/test/tmp/dist/types/project_query.js +0 -2
  73. package/test/tmp/dist/types/project_query.js.map +0 -1
  74. package/test/tmp/dist/utils/utils.d.ts +0 -11
  75. package/test/tmp/dist/utils/utils.js +0 -13
  76. package/test/tmp/dist/utils/utils.js.map +0 -1
  77. package/test/tmp/package-lock.json +0 -573
  78. package/test/tmp/src/Brief_News_Category.ts +0 -94
  79. package/test/tmp/src/Client.ts +0 -106
  80. package/test/tmp/src/Institution.ts +0 -103
  81. package/test/tmp/src/Project.ts +0 -94
  82. package/test/tmp/src/types/brief_news_category.ts +0 -7
  83. package/test/tmp/src/types/brief_news_category_post.ts +0 -7
  84. package/test/tmp/src/types/brief_news_category_put.ts +0 -7
  85. package/test/tmp/src/types/brief_news_category_query.ts +0 -26
  86. package/test/tmp/src/types/client.ts +0 -5
  87. package/test/tmp/src/types/client_post.ts +0 -5
  88. package/test/tmp/src/types/client_put.ts +0 -5
  89. package/test/tmp/src/types/client_query.ts +0 -18
  90. package/test/tmp/src/types/institution.ts +0 -4
  91. package/test/tmp/src/types/institution_post.ts +0 -4
  92. package/test/tmp/src/types/institution_put.ts +0 -4
  93. package/test/tmp/src/types/institution_query.ts +0 -14
  94. package/test/tmp/src/types/project.ts +0 -7
  95. package/test/tmp/src/types/project_post.ts +0 -7
  96. package/test/tmp/src/types/project_put.ts +0 -7
  97. package/test/tmp/src/types/project_query.ts +0 -27
@@ -1,106 +0,0 @@
1
- import ky from "ky";
2
- import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
3
-
4
- import { Collection_Project } from "./Project.js"
5
- import { Collection_Brief_News_Category } from "./Brief_News_Category.js"
6
-
7
- import { client } from "./types/client.js";
8
- import { client_query } from "./types/client_query.js";
9
- import { client_put } from "./types/client_put.js";
10
- import { client_post } from "./types/client_post.js";
11
-
12
- export class Collection_Client {
13
- path: string[]
14
- get_auth: () => Promise<any>
15
-
16
- constructor(path: string[], get_auth: () => Promise<any>) {
17
- this.path = path;
18
- this.get_auth = get_auth;
19
- }
20
-
21
-
22
- async query(query: client_query): Promise<client[]>{
23
- try {
24
- let result = await ky.get(this.path.join('/'), {
25
- headers: {
26
- authorization: await this.get_auth()
27
- },
28
- searchParams: encode_search_params(query)
29
- }).json() as Response_Multiple<client>;
30
- return result.data;
31
- } catch(err){
32
- return Promise.reject(err)
33
- }
34
- }
35
-
36
- async post(document: client_post): Promise<client>{
37
- try {
38
- let result = await ky.post(this.path.join('/'), {
39
- headers: {
40
- authorization: await this.get_auth()
41
- },
42
- json: document
43
- }).json() as Response<client>;
44
- return result.data;
45
- } catch(err){
46
- return Promise.reject(err)
47
- }
48
- }
49
-
50
- document(document_id: string) {
51
- let path = this.path;
52
- let get_auth = this.get_auth;
53
- return {
54
- async get(): Promise<client>{
55
- try {
56
- let result = await ky.get([...path, document_id].join('/'), {
57
- headers: {
58
- authorization: await get_auth()
59
- },
60
- }).json() as Response<client>;
61
- return result.data;
62
- } catch(err){
63
- return Promise.reject(err)
64
- }
65
- },
66
-
67
- async put(update: client_put): Promise<client>{
68
- try {
69
- let result = await ky.put([...path, document_id].join('/'), {
70
- headers: {
71
- authorization: await get_auth()
72
- },
73
- json: update
74
- }).json() as Response<client>;
75
- return result.data;
76
- } catch(err){
77
- return Promise.reject(err)
78
- }
79
- },
80
-
81
- async remove(): Promise<client>{
82
- try {
83
- let result = await ky.delete([...path, document_id].join('/'), {
84
- headers: {
85
- authorization: await get_auth()
86
- },
87
- }).json() as Response<client>;
88
- return result.data;
89
- } catch(err){
90
- return Promise.reject(err)
91
- }
92
- },
93
-
94
- collection(collection_id: "project" | "brief_news_category") {
95
- switch(collection_id) {
96
- case "project":
97
- return new Collection_Project([...path, document_id, "project"], get_auth);
98
- case "brief_news_category":
99
- return new Collection_Brief_News_Category([...path, document_id, "brief_news_category"], get_auth);
100
- default:
101
- throw new Error(`Api does not have the collection ${collection_id}`)
102
- }
103
- }
104
- }
105
- }
106
- }
@@ -1,103 +0,0 @@
1
- import ky from "ky";
2
- import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
3
-
4
- import { Collection_Client } from "./Client.js"
5
-
6
- import { institution } from "./types/institution.js";
7
- import { institution_query } from "./types/institution_query.js";
8
- import { institution_put } from "./types/institution_put.js";
9
- import { institution_post } from "./types/institution_post.js";
10
-
11
- export class Collection_Institution {
12
- path: string[]
13
- get_auth: () => Promise<any>
14
-
15
- constructor(path: string[], get_auth: () => Promise<any>) {
16
- this.path = path;
17
- this.get_auth = get_auth;
18
- }
19
-
20
-
21
- async query(query: institution_query): Promise<institution[]>{
22
- try {
23
- let result = await ky.get(this.path.join('/'), {
24
- headers: {
25
- authorization: await this.get_auth()
26
- },
27
- searchParams: encode_search_params(query)
28
- }).json() as Response_Multiple<institution>;
29
- return result.data;
30
- } catch(err){
31
- return Promise.reject(err)
32
- }
33
- }
34
-
35
- async post(document: institution_post): Promise<institution>{
36
- try {
37
- let result = await ky.post(this.path.join('/'), {
38
- headers: {
39
- authorization: await this.get_auth()
40
- },
41
- json: document
42
- }).json() as Response<institution>;
43
- return result.data;
44
- } catch(err){
45
- return Promise.reject(err)
46
- }
47
- }
48
-
49
- document(document_id: string) {
50
- let path = this.path;
51
- let get_auth = this.get_auth;
52
- return {
53
- async get(): Promise<institution>{
54
- try {
55
- let result = await ky.get([...path, document_id].join('/'), {
56
- headers: {
57
- authorization: await get_auth()
58
- },
59
- }).json() as Response<institution>;
60
- return result.data;
61
- } catch(err){
62
- return Promise.reject(err)
63
- }
64
- },
65
-
66
- async put(update: institution_put): Promise<institution>{
67
- try {
68
- let result = await ky.put([...path, document_id].join('/'), {
69
- headers: {
70
- authorization: await get_auth()
71
- },
72
- json: update
73
- }).json() as Response<institution>;
74
- return result.data;
75
- } catch(err){
76
- return Promise.reject(err)
77
- }
78
- },
79
-
80
- async remove(): Promise<institution>{
81
- try {
82
- let result = await ky.delete([...path, document_id].join('/'), {
83
- headers: {
84
- authorization: await get_auth()
85
- },
86
- }).json() as Response<institution>;
87
- return result.data;
88
- } catch(err){
89
- return Promise.reject(err)
90
- }
91
- },
92
-
93
- collection(collection_id: "client") {
94
- switch(collection_id) {
95
- case "client":
96
- return new Collection_Client([...path, document_id, "client"], get_auth);
97
- default:
98
- throw new Error(`Api does not have the collection ${collection_id}`)
99
- }
100
- }
101
- }
102
- }
103
- }
@@ -1,94 +0,0 @@
1
- import ky from "ky";
2
- import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
3
-
4
-
5
- import { project } from "./types/project.js";
6
- import { project_query } from "./types/project_query.js";
7
- import { project_put } from "./types/project_put.js";
8
- import { project_post } from "./types/project_post.js";
9
-
10
- export class Collection_Project {
11
- path: string[]
12
- get_auth: () => Promise<any>
13
-
14
- constructor(path: string[], get_auth: () => Promise<any>) {
15
- this.path = path;
16
- this.get_auth = get_auth;
17
- }
18
-
19
-
20
- async query(query: project_query): Promise<project[]>{
21
- try {
22
- let result = await ky.get(this.path.join('/'), {
23
- headers: {
24
- authorization: await this.get_auth()
25
- },
26
- searchParams: encode_search_params(query)
27
- }).json() as Response_Multiple<project>;
28
- return result.data;
29
- } catch(err){
30
- return Promise.reject(err)
31
- }
32
- }
33
-
34
- async post(document: project_post): Promise<project>{
35
- try {
36
- let result = await ky.post(this.path.join('/'), {
37
- headers: {
38
- authorization: await this.get_auth()
39
- },
40
- json: document
41
- }).json() as Response<project>;
42
- return result.data;
43
- } catch(err){
44
- return Promise.reject(err)
45
- }
46
- }
47
-
48
- document(document_id: string) {
49
- let path = this.path;
50
- let get_auth = this.get_auth;
51
- return {
52
- async get(): Promise<project>{
53
- try {
54
- let result = await ky.get([...path, document_id].join('/'), {
55
- headers: {
56
- authorization: await get_auth()
57
- },
58
- }).json() as Response<project>;
59
- return result.data;
60
- } catch(err){
61
- return Promise.reject(err)
62
- }
63
- },
64
-
65
- async put(update: project_put): Promise<project>{
66
- try {
67
- let result = await ky.put([...path, document_id].join('/'), {
68
- headers: {
69
- authorization: await get_auth()
70
- },
71
- json: update
72
- }).json() as Response<project>;
73
- return result.data;
74
- } catch(err){
75
- return Promise.reject(err)
76
- }
77
- },
78
-
79
- async remove(): Promise<project>{
80
- try {
81
- let result = await ky.delete([...path, document_id].join('/'), {
82
- headers: {
83
- authorization: await get_auth()
84
- },
85
- }).json() as Response<project>;
86
- return result.data;
87
- } catch(err){
88
- return Promise.reject(err)
89
- }
90
- },
91
-
92
- }
93
- }
94
- }
@@ -1,7 +0,0 @@
1
- export type brief_news_category = {
2
- "_id": string
3
- "name": string
4
- "slug": string
5
- "institution_id": string
6
- "client_id": string
7
- }
@@ -1,7 +0,0 @@
1
- export type brief_news_category_post = {
2
- "_id"?: string
3
- "name": string
4
- "slug": string
5
- "institution_id": string
6
- "client_id": string
7
- }
@@ -1,7 +0,0 @@
1
- export type brief_news_category_put = {
2
- "_id"?: string
3
- "name"?: string
4
- "slug"?: string
5
- "institution_id"?: string
6
- "client_id"?: string
7
- }
@@ -1,26 +0,0 @@
1
- export type brief_news_category_query = {
2
- "limit"?: number
3
- "cursor"?: string
4
- "sort_order"?: ("ascending" | "descending")
5
- "_id"?: string
6
- "_id_gt"?: string
7
- "_id_lt"?: string
8
- "_id_in"?: string[]
9
- "name"?: string
10
- "name_gt"?: string
11
- "name_lt"?: string
12
- "name_in"?: string[]
13
- "slug"?: string
14
- "slug_gt"?: string
15
- "slug_lt"?: string
16
- "slug_in"?: string[]
17
- "institution_id"?: string
18
- "institution_id_gt"?: string
19
- "institution_id_lt"?: string
20
- "institution_id_in"?: string[]
21
- "client_id"?: string
22
- "client_id_gt"?: string
23
- "client_id_lt"?: string
24
- "client_id_in"?: string[]
25
- "sort"?: ("_id" | "name" | "slug" | "institution_id" | "client_id")
26
- }
@@ -1,5 +0,0 @@
1
- export type client = {
2
- "_id": string
3
- "name": string
4
- "institution_id": string
5
- }
@@ -1,5 +0,0 @@
1
- export type client_post = {
2
- "_id"?: string
3
- "name": string
4
- "institution_id": string
5
- }
@@ -1,5 +0,0 @@
1
- export type client_put = {
2
- "_id"?: string
3
- "name"?: string
4
- "institution_id"?: string
5
- }
@@ -1,18 +0,0 @@
1
- export type client_query = {
2
- "limit"?: number
3
- "cursor"?: string
4
- "sort_order"?: ("ascending" | "descending")
5
- "_id"?: string
6
- "_id_gt"?: string
7
- "_id_lt"?: string
8
- "_id_in"?: string[]
9
- "name"?: string
10
- "name_gt"?: string
11
- "name_lt"?: string
12
- "name_in"?: string[]
13
- "institution_id"?: string
14
- "institution_id_gt"?: string
15
- "institution_id_lt"?: string
16
- "institution_id_in"?: string[]
17
- "sort"?: ("_id" | "name" | "institution_id")
18
- }
@@ -1,4 +0,0 @@
1
- export type institution = {
2
- "_id": string
3
- "name": string
4
- }
@@ -1,4 +0,0 @@
1
- export type institution_post = {
2
- "_id"?: string
3
- "name": string
4
- }
@@ -1,4 +0,0 @@
1
- export type institution_put = {
2
- "_id"?: string
3
- "name"?: string
4
- }
@@ -1,14 +0,0 @@
1
- export type institution_query = {
2
- "limit"?: number
3
- "cursor"?: string
4
- "sort_order"?: ("ascending" | "descending")
5
- "_id"?: string
6
- "_id_gt"?: string
7
- "_id_lt"?: string
8
- "_id_in"?: string[]
9
- "name"?: string
10
- "name_gt"?: string
11
- "name_lt"?: string
12
- "name_in"?: string[]
13
- "sort"?: ("_id" | "name")
14
- }
@@ -1,7 +0,0 @@
1
- export type project = {
2
- "_id": string
3
- "name": string
4
- "institution_id": string
5
- "client_id": string
6
- "project_number": number
7
- }
@@ -1,7 +0,0 @@
1
- export type project_post = {
2
- "_id"?: string
3
- "name": string
4
- "institution_id": string
5
- "client_id": string
6
- "project_number": number
7
- }
@@ -1,7 +0,0 @@
1
- export type project_put = {
2
- "_id"?: string
3
- "name"?: string
4
- "institution_id"?: string
5
- "client_id"?: string
6
- "project_number"?: number
7
- }
@@ -1,27 +0,0 @@
1
- export type project_query = {
2
- "limit"?: number
3
- "cursor"?: string
4
- "sort_order"?: ("ascending" | "descending")
5
- "_id"?: string
6
- "_id_gt"?: string
7
- "_id_lt"?: string
8
- "_id_in"?: string[]
9
- "name"?: string
10
- "name_gt"?: string
11
- "name_lt"?: string
12
- "name_in"?: string[]
13
- "institution_id"?: string
14
- "institution_id_gt"?: string
15
- "institution_id_lt"?: string
16
- "institution_id_in"?: string[]
17
- "client_id"?: string
18
- "client_id_gt"?: string
19
- "client_id_lt"?: string
20
- "client_id_in"?: string[]
21
- "project_number"?: number
22
- "project_number_gt"?: number
23
- "project_number_gte"?: number
24
- "project_number_lt"?: number
25
- "project_number_lte"?: number
26
- "sort"?: ("_id" | "name" | "institution_id" | "client_id" | "project_number")
27
- }