@sfxcode/nuxt-mongocamp-server 1.0.4 → 1.0.6

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 (127) hide show
  1. package/dist/module.d.mts +9 -0
  2. package/dist/module.d.ts +9 -2
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +557 -4
  5. package/dist/runtime/api/apis/AdminApi.d.ts +181 -0
  6. package/dist/runtime/api/apis/AdminApi.mjs +509 -0
  7. package/dist/runtime/api/apis/ApplicationApi.d.ts +65 -0
  8. package/dist/runtime/api/apis/ApplicationApi.mjs +164 -0
  9. package/dist/runtime/api/apis/AuthApi.d.ts +104 -0
  10. package/dist/runtime/api/apis/AuthApi.mjs +296 -0
  11. package/dist/runtime/api/apis/BucketApi.d.ts +67 -0
  12. package/dist/runtime/api/apis/BucketApi.mjs +160 -0
  13. package/dist/runtime/api/apis/CollectionApi.d.ts +161 -0
  14. package/dist/runtime/api/apis/CollectionApi.mjs +435 -0
  15. package/dist/runtime/api/apis/DatabaseApi.d.ts +77 -0
  16. package/dist/runtime/api/apis/DatabaseApi.mjs +196 -0
  17. package/dist/runtime/api/apis/DocumentApi.d.ts +188 -0
  18. package/dist/runtime/api/apis/DocumentApi.mjs +465 -0
  19. package/dist/runtime/api/apis/FileApi.d.ts +125 -0
  20. package/dist/runtime/api/apis/FileApi.mjs +355 -0
  21. package/dist/runtime/api/apis/IndexApi.d.ts +137 -0
  22. package/dist/runtime/api/apis/IndexApi.mjs +367 -0
  23. package/dist/runtime/api/apis/InformationApi.d.ts +28 -0
  24. package/dist/runtime/api/apis/InformationApi.mjs +29 -0
  25. package/dist/runtime/api/apis/JobsApi.d.ts +94 -0
  26. package/dist/runtime/api/apis/JobsApi.mjs +252 -0
  27. package/dist/runtime/api/apis/index.d.ts +11 -0
  28. package/dist/runtime/api/apis/index.mjs +11 -0
  29. package/dist/runtime/api/index.d.ts +3 -0
  30. package/dist/runtime/api/index.mjs +3 -0
  31. package/dist/runtime/api/models/BucketInformation.d.ts +49 -0
  32. package/dist/runtime/api/models/BucketInformation.mjs +36 -0
  33. package/dist/runtime/api/models/CollectionStatus.d.ts +107 -0
  34. package/dist/runtime/api/models/CollectionStatus.mjs +63 -0
  35. package/dist/runtime/api/models/DatabaseInfo.d.ts +57 -0
  36. package/dist/runtime/api/models/DatabaseInfo.mjs +39 -0
  37. package/dist/runtime/api/models/DeleteResponse.d.ts +37 -0
  38. package/dist/runtime/api/models/DeleteResponse.mjs +30 -0
  39. package/dist/runtime/api/models/ErrorDescription.d.ts +43 -0
  40. package/dist/runtime/api/models/ErrorDescription.mjs +33 -0
  41. package/dist/runtime/api/models/FileInformation.d.ts +63 -0
  42. package/dist/runtime/api/models/FileInformation.mjs +42 -0
  43. package/dist/runtime/api/models/Grant.d.ts +55 -0
  44. package/dist/runtime/api/models/Grant.mjs +39 -0
  45. package/dist/runtime/api/models/IndexCreateRequest.d.ts +40 -0
  46. package/dist/runtime/api/models/IndexCreateRequest.mjs +34 -0
  47. package/dist/runtime/api/models/IndexCreateResponse.d.ts +31 -0
  48. package/dist/runtime/api/models/IndexCreateResponse.mjs +27 -0
  49. package/dist/runtime/api/models/IndexDropResponse.d.ts +31 -0
  50. package/dist/runtime/api/models/IndexDropResponse.mjs +27 -0
  51. package/dist/runtime/api/models/IndexOptionsRequest.d.ts +73 -0
  52. package/dist/runtime/api/models/IndexOptionsRequest.mjs +41 -0
  53. package/dist/runtime/api/models/InsertResponse.d.ts +37 -0
  54. package/dist/runtime/api/models/InsertResponse.mjs +30 -0
  55. package/dist/runtime/api/models/JobConfig.d.ts +61 -0
  56. package/dist/runtime/api/models/JobConfig.mjs +42 -0
  57. package/dist/runtime/api/models/JobInformation.d.ts +79 -0
  58. package/dist/runtime/api/models/JobInformation.mjs +49 -0
  59. package/dist/runtime/api/models/JsonSchema.d.ts +46 -0
  60. package/dist/runtime/api/models/JsonSchema.mjs +38 -0
  61. package/dist/runtime/api/models/JsonSchemaDefinition.d.ts +59 -0
  62. package/dist/runtime/api/models/JsonSchemaDefinition.mjs +39 -0
  63. package/dist/runtime/api/models/JsonValueAny.d.ts +31 -0
  64. package/dist/runtime/api/models/JsonValueAny.mjs +27 -0
  65. package/dist/runtime/api/models/JsonValueBoolean.d.ts +31 -0
  66. package/dist/runtime/api/models/JsonValueBoolean.mjs +27 -0
  67. package/dist/runtime/api/models/JsonValueString.d.ts +31 -0
  68. package/dist/runtime/api/models/JsonValueString.mjs +27 -0
  69. package/dist/runtime/api/models/Login.d.ts +37 -0
  70. package/dist/runtime/api/models/Login.mjs +30 -0
  71. package/dist/runtime/api/models/LoginResult.d.ts +44 -0
  72. package/dist/runtime/api/models/LoginResult.mjs +37 -0
  73. package/dist/runtime/api/models/MongoAggregateRequest.d.ts +38 -0
  74. package/dist/runtime/api/models/MongoAggregateRequest.mjs +34 -0
  75. package/dist/runtime/api/models/MongoCampConfiguration.d.ts +55 -0
  76. package/dist/runtime/api/models/MongoCampConfiguration.mjs +39 -0
  77. package/dist/runtime/api/models/MongoFindRequest.d.ts +49 -0
  78. package/dist/runtime/api/models/MongoFindRequest.mjs +33 -0
  79. package/dist/runtime/api/models/MongoIndex.d.ts +103 -0
  80. package/dist/runtime/api/models/MongoIndex.mjs +60 -0
  81. package/dist/runtime/api/models/PasswordUpdateRequest.d.ts +31 -0
  82. package/dist/runtime/api/models/PasswordUpdateRequest.mjs +27 -0
  83. package/dist/runtime/api/models/PipelineStage.d.ts +37 -0
  84. package/dist/runtime/api/models/PipelineStage.mjs +30 -0
  85. package/dist/runtime/api/models/Role.d.ts +44 -0
  86. package/dist/runtime/api/models/Role.mjs +37 -0
  87. package/dist/runtime/api/models/SchemaAnalysis.d.ts +50 -0
  88. package/dist/runtime/api/models/SchemaAnalysis.mjs +40 -0
  89. package/dist/runtime/api/models/SchemaAnalysisField.d.ts +62 -0
  90. package/dist/runtime/api/models/SchemaAnalysisField.mjs +45 -0
  91. package/dist/runtime/api/models/SchemaAnalysisFieldType.d.ts +43 -0
  92. package/dist/runtime/api/models/SchemaAnalysisFieldType.mjs +33 -0
  93. package/dist/runtime/api/models/SettingsResponse.d.ts +51 -0
  94. package/dist/runtime/api/models/SettingsResponse.mjs +34 -0
  95. package/dist/runtime/api/models/UpdateFileInformationRequest.d.ts +39 -0
  96. package/dist/runtime/api/models/UpdateFileInformationRequest.mjs +29 -0
  97. package/dist/runtime/api/models/UpdateRequest.d.ts +41 -0
  98. package/dist/runtime/api/models/UpdateRequest.mjs +30 -0
  99. package/dist/runtime/api/models/UpdateResponse.d.ts +49 -0
  100. package/dist/runtime/api/models/UpdateResponse.mjs +36 -0
  101. package/dist/runtime/api/models/UpdateRoleRequest.d.ts +38 -0
  102. package/dist/runtime/api/models/UpdateRoleRequest.mjs +34 -0
  103. package/dist/runtime/api/models/UserInformation.d.ts +49 -0
  104. package/dist/runtime/api/models/UserInformation.mjs +35 -0
  105. package/dist/runtime/api/models/UserProfile.d.ts +56 -0
  106. package/dist/runtime/api/models/UserProfile.mjs +41 -0
  107. package/dist/runtime/api/models/Version.d.ts +43 -0
  108. package/dist/runtime/api/models/Version.mjs +33 -0
  109. package/dist/runtime/api/models/index.d.ts +39 -0
  110. package/dist/runtime/api/models/index.mjs +39 -0
  111. package/dist/runtime/api/runtime.d.ts +182 -0
  112. package/dist/runtime/api/runtime.mjs +289 -0
  113. package/dist/runtime/composables/mongocampApi.d.ts +14 -0
  114. package/dist/runtime/composables/mongocampApi.mjs +45 -0
  115. package/dist/runtime/composables/mongocampAuth.d.ts +8 -0
  116. package/dist/runtime/composables/mongocampAuth.mjs +28 -0
  117. package/dist/runtime/composables/mongocampSearch.d.ts +11 -0
  118. package/dist/runtime/composables/mongocampSearch.mjs +20 -0
  119. package/dist/runtime/composables/mongocampStorage.d.ts +0 -0
  120. package/dist/runtime/composables/mongocampStorage.mjs +5 -0
  121. package/dist/runtime/composables/mongocampUrl.d.ts +1 -0
  122. package/dist/runtime/composables/mongocampUrl.mjs +5 -0
  123. package/dist/runtime/composables/mongocampUser.d.ts +3 -0
  124. package/dist/runtime/composables/mongocampUser.mjs +4 -0
  125. package/dist/types.d.mts +15 -0
  126. package/dist/types.d.ts +2 -8
  127. package/package.json +14 -13
@@ -0,0 +1,289 @@
1
+ export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
2
+ export class Configuration {
3
+ constructor(configuration = {}) {
4
+ this.configuration = configuration;
5
+ }
6
+ set config(configuration) {
7
+ this.configuration = configuration;
8
+ }
9
+ get basePath() {
10
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
11
+ }
12
+ get fetchApi() {
13
+ return this.configuration.fetchApi;
14
+ }
15
+ get middleware() {
16
+ return this.configuration.middleware || [];
17
+ }
18
+ get queryParamsStringify() {
19
+ return this.configuration.queryParamsStringify || querystring;
20
+ }
21
+ get username() {
22
+ return this.configuration.username;
23
+ }
24
+ get password() {
25
+ return this.configuration.password;
26
+ }
27
+ get apiKey() {
28
+ const apiKey = this.configuration.apiKey;
29
+ if (apiKey) {
30
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
31
+ }
32
+ return void 0;
33
+ }
34
+ get accessToken() {
35
+ const accessToken = this.configuration.accessToken;
36
+ if (accessToken) {
37
+ return typeof accessToken === "function" ? accessToken : async () => accessToken;
38
+ }
39
+ return void 0;
40
+ }
41
+ get headers() {
42
+ return this.configuration.headers;
43
+ }
44
+ get credentials() {
45
+ return this.configuration.credentials;
46
+ }
47
+ }
48
+ export const DefaultConfig = new Configuration();
49
+ export class BaseAPI {
50
+ constructor(configuration = DefaultConfig) {
51
+ this.configuration = configuration;
52
+ this.middleware = configuration.middleware;
53
+ }
54
+ static jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
55
+ middleware;
56
+ withMiddleware(...middlewares) {
57
+ const next = this.clone();
58
+ next.middleware = next.middleware.concat(...middlewares);
59
+ return next;
60
+ }
61
+ withPreMiddleware(...preMiddlewares) {
62
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
63
+ return this.withMiddleware(...middlewares);
64
+ }
65
+ withPostMiddleware(...postMiddlewares) {
66
+ const middlewares = postMiddlewares.map((post) => ({ post }));
67
+ return this.withMiddleware(...middlewares);
68
+ }
69
+ /**
70
+ * Check if the given MIME is a JSON MIME.
71
+ * JSON MIME examples:
72
+ * application/json
73
+ * application/json; charset=UTF8
74
+ * APPLICATION/JSON
75
+ * application/vnd.company+json
76
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
77
+ * @return True if the given MIME is JSON, false otherwise.
78
+ */
79
+ isJsonMime(mime) {
80
+ if (!mime) {
81
+ return false;
82
+ }
83
+ return BaseAPI.jsonRegex.test(mime);
84
+ }
85
+ async request(context, initOverrides) {
86
+ const { url, init } = await this.createFetchParams(context, initOverrides);
87
+ const response = await this.fetchApi(url, init);
88
+ if (response && (response.status >= 200 && response.status < 300)) {
89
+ return response;
90
+ }
91
+ throw new ResponseError(response, "Response returned an error code");
92
+ }
93
+ async createFetchParams(context, initOverrides) {
94
+ let url = this.configuration.basePath + context.path;
95
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
96
+ url += "?" + this.configuration.queryParamsStringify(context.query);
97
+ }
98
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
99
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
100
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
101
+ const initParams = {
102
+ method: context.method,
103
+ headers,
104
+ body: context.body,
105
+ credentials: this.configuration.credentials
106
+ };
107
+ const overriddenInit = {
108
+ ...initParams,
109
+ ...await initOverrideFn({
110
+ init: initParams,
111
+ context
112
+ })
113
+ };
114
+ let body;
115
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
116
+ body = overriddenInit.body;
117
+ } else if (this.isJsonMime(headers["Content-Type"])) {
118
+ body = JSON.stringify(overriddenInit.body);
119
+ } else {
120
+ body = overriddenInit.body;
121
+ }
122
+ const init = {
123
+ ...overriddenInit,
124
+ body
125
+ };
126
+ return { url, init };
127
+ }
128
+ fetchApi = async (url, init) => {
129
+ let fetchParams = { url, init };
130
+ for (const middleware of this.middleware) {
131
+ if (middleware.pre) {
132
+ fetchParams = await middleware.pre({
133
+ fetch: this.fetchApi,
134
+ ...fetchParams
135
+ }) || fetchParams;
136
+ }
137
+ }
138
+ let response = void 0;
139
+ try {
140
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
141
+ } catch (e) {
142
+ for (const middleware of this.middleware) {
143
+ if (middleware.onError) {
144
+ response = await middleware.onError({
145
+ fetch: this.fetchApi,
146
+ url: fetchParams.url,
147
+ init: fetchParams.init,
148
+ error: e,
149
+ response: response ? response.clone() : void 0
150
+ }) || response;
151
+ }
152
+ }
153
+ if (response === void 0) {
154
+ if (e instanceof Error) {
155
+ throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
156
+ } else {
157
+ throw e;
158
+ }
159
+ }
160
+ }
161
+ for (const middleware of this.middleware) {
162
+ if (middleware.post) {
163
+ response = await middleware.post({
164
+ fetch: this.fetchApi,
165
+ url: fetchParams.url,
166
+ init: fetchParams.init,
167
+ response: response.clone()
168
+ }) || response;
169
+ }
170
+ }
171
+ return response;
172
+ };
173
+ /**
174
+ * Create a shallow clone of `this` by constructing a new instance
175
+ * and then shallow cloning data members.
176
+ */
177
+ clone() {
178
+ const constructor = this.constructor;
179
+ const next = new constructor(this.configuration);
180
+ next.middleware = this.middleware.slice();
181
+ return next;
182
+ }
183
+ }
184
+ ;
185
+ function isBlob(value) {
186
+ return typeof Blob !== "undefined" && value instanceof Blob;
187
+ }
188
+ function isFormData(value) {
189
+ return typeof FormData !== "undefined" && value instanceof FormData;
190
+ }
191
+ export class ResponseError extends Error {
192
+ constructor(response, msg) {
193
+ super(msg);
194
+ this.response = response;
195
+ }
196
+ name = "ResponseError";
197
+ }
198
+ export class FetchError extends Error {
199
+ constructor(cause, msg) {
200
+ super(msg);
201
+ this.cause = cause;
202
+ }
203
+ name = "FetchError";
204
+ }
205
+ export class RequiredError extends Error {
206
+ constructor(field, msg) {
207
+ super(msg);
208
+ this.field = field;
209
+ }
210
+ name = "RequiredError";
211
+ }
212
+ export const COLLECTION_FORMATS = {
213
+ csv: ",",
214
+ ssv: " ",
215
+ tsv: " ",
216
+ pipes: "|"
217
+ };
218
+ export function exists(json, key) {
219
+ const value = json[key];
220
+ return value !== null && value !== void 0;
221
+ }
222
+ export function querystring(params, prefix = "") {
223
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
224
+ }
225
+ function querystringSingleKey(key, value, keyPrefix = "") {
226
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
227
+ if (value instanceof Array) {
228
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
229
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
230
+ }
231
+ if (value instanceof Set) {
232
+ const valueAsArray = Array.from(value);
233
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
234
+ }
235
+ if (value instanceof Date) {
236
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
237
+ }
238
+ if (value instanceof Object) {
239
+ return querystring(value, fullKey);
240
+ }
241
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
242
+ }
243
+ export function mapValues(data, fn) {
244
+ return Object.keys(data).reduce(
245
+ (acc, key) => ({ ...acc, [key]: fn(data[key]) }),
246
+ {}
247
+ );
248
+ }
249
+ export function canConsumeForm(consumes) {
250
+ for (const consume of consumes) {
251
+ if ("multipart/form-data" === consume.contentType) {
252
+ return true;
253
+ }
254
+ }
255
+ return false;
256
+ }
257
+ export class JSONApiResponse {
258
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
259
+ this.raw = raw;
260
+ this.transformer = transformer;
261
+ }
262
+ async value() {
263
+ return this.transformer(await this.raw.json());
264
+ }
265
+ }
266
+ export class VoidApiResponse {
267
+ constructor(raw) {
268
+ this.raw = raw;
269
+ }
270
+ async value() {
271
+ return void 0;
272
+ }
273
+ }
274
+ export class BlobApiResponse {
275
+ constructor(raw) {
276
+ this.raw = raw;
277
+ }
278
+ async value() {
279
+ return await this.raw.blob();
280
+ }
281
+ }
282
+ export class TextApiResponse {
283
+ constructor(raw) {
284
+ this.raw = raw;
285
+ }
286
+ async value() {
287
+ return await this.raw.text();
288
+ }
289
+ }
@@ -0,0 +1,14 @@
1
+ import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, InformationApi, JobsApi } from '../api';
2
+ export declare function useMongocampApi(): {
3
+ adminApi: AdminApi;
4
+ applicationApi: ApplicationApi;
5
+ authApi: AuthApi;
6
+ bucketApi: BucketApi;
7
+ collectionApi: CollectionApi;
8
+ databaseApi: DatabaseApi;
9
+ documentApi: DocumentApi;
10
+ fileApi: FileApi;
11
+ indexApi: IndexApi;
12
+ informationApi: InformationApi;
13
+ jobApi: JobsApi;
14
+ };
@@ -0,0 +1,45 @@
1
+ import {
2
+ AdminApi,
3
+ ApplicationApi,
4
+ AuthApi,
5
+ BucketApi,
6
+ CollectionApi,
7
+ Configuration,
8
+ DatabaseApi,
9
+ DocumentApi,
10
+ FileApi,
11
+ IndexApi,
12
+ InformationApi,
13
+ JobsApi
14
+ } from "../api/index.mjs";
15
+ import { useMongocampUrl } from "./mongocampUrl.mjs";
16
+ import { useMongocampStorage } from "./mongocampStorage.mjs";
17
+ export function useMongocampApi() {
18
+ const url = useMongocampUrl();
19
+ const token = useMongocampStorage();
20
+ const configuration = new Configuration({ basePath: url, accessToken: token.value.token });
21
+ const adminApi = new AdminApi(configuration);
22
+ const applicationApi = new ApplicationApi(configuration);
23
+ const authApi = new AuthApi(configuration);
24
+ const bucketApi = new BucketApi(configuration);
25
+ const collectionApi = new CollectionApi(configuration);
26
+ const databaseApi = new DatabaseApi(configuration);
27
+ const documentApi = new DocumentApi(configuration);
28
+ const fileApi = new FileApi(configuration);
29
+ const indexApi = new IndexApi(configuration);
30
+ const informationApi = new InformationApi(configuration);
31
+ const jobApi = new JobsApi(configuration);
32
+ return {
33
+ adminApi,
34
+ applicationApi,
35
+ authApi,
36
+ bucketApi,
37
+ collectionApi,
38
+ databaseApi,
39
+ documentApi,
40
+ fileApi,
41
+ indexApi,
42
+ informationApi,
43
+ jobApi
44
+ };
45
+ }
@@ -0,0 +1,8 @@
1
+ import type { UserProfile } from '../api';
2
+ export declare function useMongocampAuth(): {
3
+ login: (loginId: string, loginPassword: string) => Promise<UserProfile>;
4
+ logout: () => void;
5
+ isLoggedIn: import("vue").ComputedRef<boolean>;
6
+ userRoles: import("vue").ComputedRef<string[]>;
7
+ userGrants: import("vue").ComputedRef<import("../api").Grant[]>;
8
+ };
@@ -0,0 +1,28 @@
1
+ import { computed } from "vue";
2
+ import { useMongocampApi } from "./mongocampApi.mjs";
3
+ import { useMongocampStorage } from "./mongocampStorage.mjs";
4
+ import { useMongocampUser } from "./mongocampUser.mjs";
5
+ export function useMongocampAuth() {
6
+ const state = useMongocampStorage();
7
+ const { authApi } = useMongocampApi();
8
+ const user = useMongocampUser();
9
+ const login = async (loginId, loginPassword) => {
10
+ logout();
11
+ const login2 = { userId: loginId, password: loginPassword };
12
+ const result = await authApi.login({ login: login2 });
13
+ state.value.token = result.authToken;
14
+ state.value.profile = result.userProfile;
15
+ user.value = result.userProfile;
16
+ return result.userProfile;
17
+ };
18
+ const logout = () => {
19
+ state.value.token = "";
20
+ const profile = { user: "", isAdmin: false };
21
+ state.value.profile = profile;
22
+ user.value = profile;
23
+ };
24
+ const isLoggedIn = computed(() => state.value?.token?.length > 0);
25
+ const userRoles = computed(() => state.value.profile.roles ?? []);
26
+ const userGrants = computed(() => state.value.profile.grants ?? []);
27
+ return { login, logout, isLoggedIn, userRoles, userGrants };
28
+ }
@@ -0,0 +1,11 @@
1
+ import type { FindRequest, MongoFindRequest } from '../api';
2
+ export declare function useMongocampSearch(): {
3
+ mongoFindRequest: (filter?: object, sort?: object, projection?: object) => MongoFindRequest;
4
+ findRequest: (collection: string, searchParameter?: MongoFindRequest, rows?: number, actualPage?: number) => FindRequest;
5
+ findAll: (collectionName: string, page?: number, sort?: string[] | undefined, projection?: string[] | undefined, rowsPerPage?: number) => Promise<{
6
+ [key: string]: string;
7
+ }[]>;
8
+ findByField: (collectionName: string, field: string, value: string, page?: number, sort?: string[] | undefined, projection?: string[] | undefined, rowsPerPage?: number) => Promise<{
9
+ [key: string]: string;
10
+ }[]>;
11
+ };
@@ -0,0 +1,20 @@
1
+ import { useRuntimeConfig } from "#app";
2
+ import { useMongocampApi } from "./mongocampApi.mjs";
3
+ export function useMongocampSearch() {
4
+ const { documentApi } = useMongocampApi();
5
+ const config = useRuntimeConfig();
6
+ const mongoFindRequest = (filter = {}, sort = {}, projection = {}) => {
7
+ return { filter, sort, projection };
8
+ };
9
+ const findRequest = (collection, searchParameter = mongoFindRequest(), rows = config.public.mongocamp?.paginationSize, actualPage = 1) => {
10
+ return { collectionName: collection, mongoFindRequest: searchParameter, rowsPerPage: rows, page: actualPage };
11
+ };
12
+ function findAll(collectionName, page = 1, sort = void 0, projection = void 0, rowsPerPage = config.public.mongocamp?.paginationSize) {
13
+ return documentApi.listDocuments({ collectionName, sort, projection, page, rowsPerPage });
14
+ }
15
+ function findByField(collectionName, field, value, page = 1, sort = void 0, projection = void 0, rowsPerPage = config.public.mongocamp?.paginationSize) {
16
+ const expression = `${field}: ${value}`;
17
+ return documentApi.listDocuments({ collectionName, filter: expression, sort, projection, page, rowsPerPage });
18
+ }
19
+ return { mongoFindRequest, findRequest, findAll, findByField };
20
+ }
File without changes
@@ -0,0 +1,5 @@
1
+ import { useSessionStorage } from "@vueuse/core";
2
+ export function useMongocampStorage() {
3
+ const profile = { user: "", isAdmin: false };
4
+ return useSessionStorage("mongocamp", { token: "", profile });
5
+ }
@@ -0,0 +1 @@
1
+ export declare function useMongocampUrl(): string;
@@ -0,0 +1,5 @@
1
+ import { useRuntimeConfig } from "#app";
2
+ export function useMongocampUrl() {
3
+ const config = useRuntimeConfig();
4
+ return config.public.mongocamp?.url;
5
+ }
@@ -0,0 +1,3 @@
1
+ import type { Ref } from 'vue';
2
+ import type { UserProfile } from '../api';
3
+ export declare function useMongocampUser(): Ref<UserProfile>;
@@ -0,0 +1,4 @@
1
+ import { useState } from "#app";
2
+ export function useMongocampUser() {
3
+ return useState("mongocamp.user");
4
+ }
@@ -0,0 +1,15 @@
1
+
2
+ import { ModuleOptions } from './module'
3
+
4
+ declare module '@nuxt/schema' {
5
+ interface NuxtConfig { ['mongocamp']?: Partial<ModuleOptions> }
6
+ interface NuxtOptions { ['mongocamp']?: ModuleOptions }
7
+ }
8
+
9
+ declare module 'nuxt/schema' {
10
+ interface NuxtConfig { ['mongocamp']?: Partial<ModuleOptions> }
11
+ interface NuxtOptions { ['mongocamp']?: ModuleOptions }
12
+ }
13
+
14
+
15
+ export { ModuleOptions, default } from './module'
package/dist/types.d.ts CHANGED
@@ -1,21 +1,15 @@
1
1
 
2
- import { ModuleOptions, ModuleHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
2
+ import { ModuleOptions } from './module'
3
3
 
4
4
  declare module '@nuxt/schema' {
5
5
  interface NuxtConfig { ['mongocamp']?: Partial<ModuleOptions> }
6
6
  interface NuxtOptions { ['mongocamp']?: ModuleOptions }
7
- interface NuxtHooks extends ModuleHooks {}
8
- interface RuntimeConfig extends ModuleRuntimeConfig {}
9
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
10
7
  }
11
8
 
12
9
  declare module 'nuxt/schema' {
13
10
  interface NuxtConfig { ['mongocamp']?: Partial<ModuleOptions> }
14
11
  interface NuxtOptions { ['mongocamp']?: ModuleOptions }
15
- interface NuxtHooks extends ModuleHooks {}
16
- interface RuntimeConfig extends ModuleRuntimeConfig {}
17
- interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
18
12
  }
19
13
 
20
14
 
21
- export { default } from './module'
15
+ export { ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-mongocamp-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -9,7 +9,7 @@
9
9
  "require": "./dist/module.cjs"
10
10
  }
11
11
  },
12
- "main": "dist/module.cjs",
12
+ "main": "./dist/module.cjs",
13
13
  "types": "./dist/types.d.ts",
14
14
  "files": [
15
15
  "dist"
@@ -18,24 +18,25 @@
18
18
  "failOnWarn": false
19
19
  },
20
20
  "dependencies": {
21
- "@nuxt/kit": "^3.6.5",
22
- "@vueuse/nuxt": "^10.3.0"
21
+ "@nuxt/kit": "^3.8.1",
22
+ "@vueuse/nuxt": "^10.5.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@iconify-json/mdi": "^1.1.53",
26
- "@nuxt/module-builder": "^0.4.0",
27
- "@nuxtjs/eslint-config-typescript": "12.0.0",
25
+ "@iconify-json/mdi": "^1.1.55",
26
+ "@nuxt/module-builder": "^0.5.3",
27
+ "@nuxtjs/eslint-config-typescript": "12.1.0",
28
28
  "@openapitools/openapi-generator-cli": "^2.7.0",
29
- "@types/node": "^20.4.5",
30
- "@unocss/nuxt": "^0.54.0",
31
- "defu": "^6.1.2",
32
- "jiti": "^1.19.1",
33
- "nuxt": "^3.6.5"
29
+ "@types/node": "^20.8.10",
30
+ "@unocss/nuxt": "^0.57.2",
31
+ "defu": "^6.1.3",
32
+ "jiti": "^1.21.0",
33
+ "nuxt": "^3.8.1"
34
34
  },
35
35
  "scripts": {
36
- "dev": "nuxi dev --port 3333 playground",
36
+ "dev": "nuxi dev playground",
37
37
  "dev:build": "nuxi build playground",
38
38
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
39
+ "dev:start": "node playground/.output/server/index.mjs",
39
40
  "lint:show": "eslint ./src/runtime",
40
41
  "lint:fix": "eslint --fix ./src/runtime",
41
42
  "api-codegen": "openapi-generator-cli generate -i http://173.249.2.248:30103/docs/docs.yaml -g typescript-fetch -o src/runtime/api --additional-properties=typescriptThreePlus=true,supportsES6=true"