@sfxcode/nuxt-mongocamp-server 0.7.0
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/README.md +38 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +9 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +72 -0
- package/dist/runtime/api/apis/AdminApi.d.ts +181 -0
- package/dist/runtime/api/apis/AdminApi.mjs +413 -0
- package/dist/runtime/api/apis/ApplicationApi.d.ts +68 -0
- package/dist/runtime/api/apis/ApplicationApi.mjs +147 -0
- package/dist/runtime/api/apis/AuthApi.d.ts +107 -0
- package/dist/runtime/api/apis/AuthApi.mjs +235 -0
- package/dist/runtime/api/apis/BucketApi.d.ts +67 -0
- package/dist/runtime/api/apis/BucketApi.mjs +128 -0
- package/dist/runtime/api/apis/CollectionApi.d.ts +161 -0
- package/dist/runtime/api/apis/CollectionApi.mjs +355 -0
- package/dist/runtime/api/apis/DatabaseApi.d.ts +77 -0
- package/dist/runtime/api/apis/DatabaseApi.mjs +156 -0
- package/dist/runtime/api/apis/DocumentApi.d.ts +188 -0
- package/dist/runtime/api/apis/DocumentApi.mjs +385 -0
- package/dist/runtime/api/apis/FileApi.d.ts +125 -0
- package/dist/runtime/api/apis/FileApi.mjs +299 -0
- package/dist/runtime/api/apis/IndexApi.d.ts +137 -0
- package/dist/runtime/api/apis/IndexApi.mjs +303 -0
- package/dist/runtime/api/apis/InformationApi.d.ts +28 -0
- package/dist/runtime/api/apis/InformationApi.mjs +21 -0
- package/dist/runtime/api/apis/JobsApi.d.ts +94 -0
- package/dist/runtime/api/apis/JobsApi.mjs +204 -0
- package/dist/runtime/api/apis/index.d.ts +11 -0
- package/dist/runtime/api/apis/index.mjs +11 -0
- package/dist/runtime/api/index.d.ts +3 -0
- package/dist/runtime/api/index.mjs +3 -0
- package/dist/runtime/api/models/BucketInformation.d.ts +45 -0
- package/dist/runtime/api/models/BucketInformation.mjs +28 -0
- package/dist/runtime/api/models/CollectionStatus.d.ts +103 -0
- package/dist/runtime/api/models/CollectionStatus.mjs +46 -0
- package/dist/runtime/api/models/DatabaseInfo.d.ts +53 -0
- package/dist/runtime/api/models/DatabaseInfo.mjs +30 -0
- package/dist/runtime/api/models/DeleteResponse.d.ts +33 -0
- package/dist/runtime/api/models/DeleteResponse.mjs +24 -0
- package/dist/runtime/api/models/ErrorDescription.d.ts +39 -0
- package/dist/runtime/api/models/ErrorDescription.mjs +26 -0
- package/dist/runtime/api/models/FileInformation.d.ts +59 -0
- package/dist/runtime/api/models/FileInformation.mjs +32 -0
- package/dist/runtime/api/models/Grant.d.ts +51 -0
- package/dist/runtime/api/models/Grant.mjs +30 -0
- package/dist/runtime/api/models/IndexCreateRequest.d.ts +36 -0
- package/dist/runtime/api/models/IndexCreateRequest.mjs +29 -0
- package/dist/runtime/api/models/IndexCreateResponse.d.ts +27 -0
- package/dist/runtime/api/models/IndexCreateResponse.mjs +22 -0
- package/dist/runtime/api/models/IndexDropResponse.d.ts +27 -0
- package/dist/runtime/api/models/IndexDropResponse.mjs +22 -0
- package/dist/runtime/api/models/IndexOptionsRequest.d.ts +69 -0
- package/dist/runtime/api/models/IndexOptionsRequest.mjs +37 -0
- package/dist/runtime/api/models/InsertResponse.d.ts +33 -0
- package/dist/runtime/api/models/InsertResponse.mjs +25 -0
- package/dist/runtime/api/models/JobConfig.d.ts +57 -0
- package/dist/runtime/api/models/JobConfig.mjs +32 -0
- package/dist/runtime/api/models/JobInformation.d.ts +75 -0
- package/dist/runtime/api/models/JobInformation.mjs +39 -0
- package/dist/runtime/api/models/JsonResultBoolean.d.ts +27 -0
- package/dist/runtime/api/models/JsonResultBoolean.mjs +22 -0
- package/dist/runtime/api/models/JsonResultString.d.ts +27 -0
- package/dist/runtime/api/models/JsonResultString.mjs +22 -0
- package/dist/runtime/api/models/JsonSchema.d.ts +42 -0
- package/dist/runtime/api/models/JsonSchema.mjs +31 -0
- package/dist/runtime/api/models/JsonSchemaDefinition.d.ts +55 -0
- package/dist/runtime/api/models/JsonSchemaDefinition.mjs +31 -0
- package/dist/runtime/api/models/Login.d.ts +33 -0
- package/dist/runtime/api/models/Login.mjs +24 -0
- package/dist/runtime/api/models/LoginResult.d.ts +40 -0
- package/dist/runtime/api/models/LoginResult.mjs +30 -0
- package/dist/runtime/api/models/Measurement.d.ts +33 -0
- package/dist/runtime/api/models/Measurement.mjs +24 -0
- package/dist/runtime/api/models/Metric.d.ts +52 -0
- package/dist/runtime/api/models/Metric.mjs +35 -0
- package/dist/runtime/api/models/MongoAggregateRequest.d.ts +34 -0
- package/dist/runtime/api/models/MongoAggregateRequest.mjs +29 -0
- package/dist/runtime/api/models/MongoFindRequest.d.ts +45 -0
- package/dist/runtime/api/models/MongoFindRequest.mjs +26 -0
- package/dist/runtime/api/models/MongoIndex.d.ts +99 -0
- package/dist/runtime/api/models/MongoIndex.mjs +45 -0
- package/dist/runtime/api/models/PasswordUpdateRequest.d.ts +27 -0
- package/dist/runtime/api/models/PasswordUpdateRequest.mjs +22 -0
- package/dist/runtime/api/models/PipelineStage.d.ts +33 -0
- package/dist/runtime/api/models/PipelineStage.mjs +24 -0
- package/dist/runtime/api/models/Role.d.ts +40 -0
- package/dist/runtime/api/models/Role.mjs +31 -0
- package/dist/runtime/api/models/SchemaAnalysis.d.ts +46 -0
- package/dist/runtime/api/models/SchemaAnalysis.mjs +33 -0
- package/dist/runtime/api/models/SchemaAnalysisField.d.ts +58 -0
- package/dist/runtime/api/models/SchemaAnalysisField.mjs +37 -0
- package/dist/runtime/api/models/SchemaAnalysisFieldType.d.ts +39 -0
- package/dist/runtime/api/models/SchemaAnalysisFieldType.mjs +26 -0
- package/dist/runtime/api/models/SettingsResponse.d.ts +47 -0
- package/dist/runtime/api/models/SettingsResponse.mjs +29 -0
- package/dist/runtime/api/models/UpdateFileInformationRequest.d.ts +35 -0
- package/dist/runtime/api/models/UpdateFileInformationRequest.mjs +25 -0
- package/dist/runtime/api/models/UpdateRequest.d.ts +37 -0
- package/dist/runtime/api/models/UpdateRequest.mjs +24 -0
- package/dist/runtime/api/models/UpdateResponse.d.ts +45 -0
- package/dist/runtime/api/models/UpdateResponse.mjs +29 -0
- package/dist/runtime/api/models/UpdateRoleRequest.d.ts +34 -0
- package/dist/runtime/api/models/UpdateRoleRequest.mjs +29 -0
- package/dist/runtime/api/models/UserInformation.d.ts +45 -0
- package/dist/runtime/api/models/UserInformation.mjs +29 -0
- package/dist/runtime/api/models/UserProfile.d.ts +52 -0
- package/dist/runtime/api/models/UserProfile.mjs +35 -0
- package/dist/runtime/api/models/Version.d.ts +39 -0
- package/dist/runtime/api/models/Version.mjs +26 -0
- package/dist/runtime/api/models/index.d.ts +39 -0
- package/dist/runtime/api/models/index.mjs +39 -0
- package/dist/runtime/api/runtime.d.ts +140 -0
- package/dist/runtime/api/runtime.mjs +196 -0
- package/dist/runtime/composables/mongocampApi.d.ts +14 -0
- package/dist/runtime/composables/mongocampApi.mjs +45 -0
- package/dist/runtime/composables/mongocampAuth.d.ts +9 -0
- package/dist/runtime/composables/mongocampAuth.mjs +52 -0
- package/dist/runtime/composables/mongocampSearch.d.ts +6 -0
- package/dist/runtime/composables/mongocampSearch.mjs +12 -0
- package/dist/runtime/composables/mongocampToken.d.ts +1 -0
- package/dist/runtime/composables/mongocampToken.mjs +10 -0
- package/dist/runtime/composables/mongocampUrl.d.ts +1 -0
- package/dist/runtime/composables/mongocampUrl.mjs +5 -0
- package/dist/runtime/composables/mongocampUser.d.ts +3 -0
- package/dist/runtime/composables/mongocampUser.mjs +2 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +6 -0
- package/dist/types.d.ts +10 -0
- package/package.json +37 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
2
|
+
const isBlob = (value) => typeof Blob !== "undefined" && value instanceof Blob;
|
|
3
|
+
export class BaseAPI {
|
|
4
|
+
constructor(configuration = new Configuration()) {
|
|
5
|
+
this.configuration = configuration;
|
|
6
|
+
this.fetchApi = async (url, init) => {
|
|
7
|
+
let fetchParams = { url, init };
|
|
8
|
+
for (const middleware of this.middleware) {
|
|
9
|
+
if (middleware.pre) {
|
|
10
|
+
fetchParams = await middleware.pre({
|
|
11
|
+
fetch: this.fetchApi,
|
|
12
|
+
...fetchParams
|
|
13
|
+
}) || fetchParams;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
17
|
+
for (const middleware of this.middleware) {
|
|
18
|
+
if (middleware.post) {
|
|
19
|
+
response = await middleware.post({
|
|
20
|
+
fetch: this.fetchApi,
|
|
21
|
+
url: fetchParams.url,
|
|
22
|
+
init: fetchParams.init,
|
|
23
|
+
response: response.clone()
|
|
24
|
+
}) || response;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return response;
|
|
28
|
+
};
|
|
29
|
+
this.middleware = configuration.middleware;
|
|
30
|
+
}
|
|
31
|
+
withMiddleware(...middlewares) {
|
|
32
|
+
const next = this.clone();
|
|
33
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
withPreMiddleware(...preMiddlewares) {
|
|
37
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
38
|
+
return this.withMiddleware(...middlewares);
|
|
39
|
+
}
|
|
40
|
+
withPostMiddleware(...postMiddlewares) {
|
|
41
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
42
|
+
return this.withMiddleware(...middlewares);
|
|
43
|
+
}
|
|
44
|
+
async request(context, initOverrides) {
|
|
45
|
+
const { url, init } = this.createFetchParams(context, initOverrides);
|
|
46
|
+
const response = await this.fetchApi(url, init);
|
|
47
|
+
if (response.status >= 200 && response.status < 300) {
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
throw response;
|
|
51
|
+
}
|
|
52
|
+
createFetchParams(context, initOverrides) {
|
|
53
|
+
let url = this.configuration.basePath + context.path;
|
|
54
|
+
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
|
|
55
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
56
|
+
}
|
|
57
|
+
const body = typeof FormData !== "undefined" && context.body instanceof FormData || context.body instanceof URLSearchParams || isBlob(context.body) ? context.body : JSON.stringify(context.body);
|
|
58
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
59
|
+
const init = {
|
|
60
|
+
method: context.method,
|
|
61
|
+
headers,
|
|
62
|
+
body,
|
|
63
|
+
credentials: this.configuration.credentials,
|
|
64
|
+
...initOverrides
|
|
65
|
+
};
|
|
66
|
+
return { url, init };
|
|
67
|
+
}
|
|
68
|
+
clone() {
|
|
69
|
+
const constructor = this.constructor;
|
|
70
|
+
const next = new constructor(this.configuration);
|
|
71
|
+
next.middleware = this.middleware.slice();
|
|
72
|
+
return next;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
export class RequiredError extends Error {
|
|
77
|
+
constructor(field, msg) {
|
|
78
|
+
super(msg);
|
|
79
|
+
this.field = field;
|
|
80
|
+
this.name = "RequiredError";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const COLLECTION_FORMATS = {
|
|
84
|
+
csv: ",",
|
|
85
|
+
ssv: " ",
|
|
86
|
+
tsv: " ",
|
|
87
|
+
pipes: "|"
|
|
88
|
+
};
|
|
89
|
+
export class Configuration {
|
|
90
|
+
constructor(configuration = {}) {
|
|
91
|
+
this.configuration = configuration;
|
|
92
|
+
}
|
|
93
|
+
get basePath() {
|
|
94
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
95
|
+
}
|
|
96
|
+
get fetchApi() {
|
|
97
|
+
return this.configuration.fetchApi;
|
|
98
|
+
}
|
|
99
|
+
get middleware() {
|
|
100
|
+
return this.configuration.middleware || [];
|
|
101
|
+
}
|
|
102
|
+
get queryParamsStringify() {
|
|
103
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
104
|
+
}
|
|
105
|
+
get username() {
|
|
106
|
+
return this.configuration.username;
|
|
107
|
+
}
|
|
108
|
+
get password() {
|
|
109
|
+
return this.configuration.password;
|
|
110
|
+
}
|
|
111
|
+
get apiKey() {
|
|
112
|
+
const apiKey = this.configuration.apiKey;
|
|
113
|
+
if (apiKey) {
|
|
114
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
get accessToken() {
|
|
119
|
+
const accessToken = this.configuration.accessToken;
|
|
120
|
+
if (accessToken) {
|
|
121
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
122
|
+
}
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
get headers() {
|
|
126
|
+
return this.configuration.headers;
|
|
127
|
+
}
|
|
128
|
+
get credentials() {
|
|
129
|
+
return this.configuration.credentials;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function exists(json, key) {
|
|
133
|
+
const value = json[key];
|
|
134
|
+
return value !== null && value !== void 0;
|
|
135
|
+
}
|
|
136
|
+
export function querystring(params, prefix = "") {
|
|
137
|
+
return Object.keys(params).map((key) => {
|
|
138
|
+
const fullKey = prefix + (prefix.length ? `[${key}]` : key);
|
|
139
|
+
const value = params[key];
|
|
140
|
+
if (value instanceof Array) {
|
|
141
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
142
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
143
|
+
}
|
|
144
|
+
if (value instanceof Date) {
|
|
145
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
146
|
+
}
|
|
147
|
+
if (value instanceof Object) {
|
|
148
|
+
return querystring(value, fullKey);
|
|
149
|
+
}
|
|
150
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
151
|
+
}).filter((part) => part.length > 0).join("&");
|
|
152
|
+
}
|
|
153
|
+
export function mapValues(data, fn) {
|
|
154
|
+
return Object.keys(data).reduce((acc, key) => ({ ...acc, [key]: fn(data[key]) }), {});
|
|
155
|
+
}
|
|
156
|
+
export function canConsumeForm(consumes) {
|
|
157
|
+
for (const consume of consumes) {
|
|
158
|
+
if (consume.contentType === "multipart/form-data") {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
export class JSONApiResponse {
|
|
165
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
166
|
+
this.raw = raw;
|
|
167
|
+
this.transformer = transformer;
|
|
168
|
+
}
|
|
169
|
+
async value() {
|
|
170
|
+
return this.transformer(await this.raw.json());
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export class VoidApiResponse {
|
|
174
|
+
constructor(raw) {
|
|
175
|
+
this.raw = raw;
|
|
176
|
+
}
|
|
177
|
+
async value() {
|
|
178
|
+
return void 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export class BlobApiResponse {
|
|
182
|
+
constructor(raw) {
|
|
183
|
+
this.raw = raw;
|
|
184
|
+
}
|
|
185
|
+
async value() {
|
|
186
|
+
return await this.raw.blob();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export class TextApiResponse {
|
|
190
|
+
constructor(raw) {
|
|
191
|
+
this.raw = raw;
|
|
192
|
+
}
|
|
193
|
+
async value() {
|
|
194
|
+
return await this.raw.text();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, InformationApi, JobsApi } from '../api';
|
|
2
|
+
export declare const 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";
|
|
15
|
+
import { useMongocampUrl } from "./mongocampUrl.mjs";
|
|
16
|
+
import { useMongocampToken } from "./mongocampToken.mjs";
|
|
17
|
+
export const useMongocampApi = () => {
|
|
18
|
+
const url = useMongocampUrl();
|
|
19
|
+
const token = useMongocampToken();
|
|
20
|
+
const configuration = new Configuration({ basePath: url, accessToken: token.value });
|
|
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,9 @@
|
|
|
1
|
+
import type { UserProfile } from '../api';
|
|
2
|
+
export declare const useMongocampAuth: () => {
|
|
3
|
+
login: (loginId: string, loginPassword: string) => Promise<UserProfile>;
|
|
4
|
+
logout: () => void;
|
|
5
|
+
userProfile: () => Promise<UserProfile>;
|
|
6
|
+
isLoggedIn: import("vue").ComputedRef<boolean>;
|
|
7
|
+
userRoles: import("vue").ComputedRef<string[]>;
|
|
8
|
+
userGrants: import("vue").ComputedRef<import("../api").Grant[]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useMongocampApi } from "./mongocampApi.mjs";
|
|
2
|
+
import { useMongocampToken } from "./mongocampToken.mjs";
|
|
3
|
+
import { useMongocampUser } from "./mongocampUser.mjs";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
export const useMongocampAuth = () => {
|
|
6
|
+
const token = useMongocampToken();
|
|
7
|
+
const user = useMongocampUser();
|
|
8
|
+
const { authApi } = useMongocampApi();
|
|
9
|
+
const setToken = (value) => {
|
|
10
|
+
token.value = value;
|
|
11
|
+
};
|
|
12
|
+
const setUser = (value) => {
|
|
13
|
+
user.value = value;
|
|
14
|
+
};
|
|
15
|
+
const login = async (loginId, loginPassword) => {
|
|
16
|
+
setToken(null);
|
|
17
|
+
const login2 = { userId: loginId, password: loginPassword };
|
|
18
|
+
const result = await authApi.login({ login: login2 });
|
|
19
|
+
setToken(result.authToken);
|
|
20
|
+
setUser(result.userProfile);
|
|
21
|
+
return result.userProfile;
|
|
22
|
+
};
|
|
23
|
+
const logout = () => {
|
|
24
|
+
setToken(null);
|
|
25
|
+
setUser(null);
|
|
26
|
+
};
|
|
27
|
+
const userProfile = async () => {
|
|
28
|
+
if (token.value && !user.value) {
|
|
29
|
+
try {
|
|
30
|
+
const profile = await authApi.userProfile();
|
|
31
|
+
setUser(profile);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
setToken(null);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return user.value;
|
|
37
|
+
};
|
|
38
|
+
const isLoggedIn = computed(() => token.value != null && user.value != null);
|
|
39
|
+
const userRoles = computed(() => {
|
|
40
|
+
if (user.value)
|
|
41
|
+
return user.value.roles;
|
|
42
|
+
else
|
|
43
|
+
return [];
|
|
44
|
+
});
|
|
45
|
+
const userGrants = computed(() => {
|
|
46
|
+
if (user.value)
|
|
47
|
+
return user.value.grants;
|
|
48
|
+
else
|
|
49
|
+
return [];
|
|
50
|
+
});
|
|
51
|
+
return { login, logout, userProfile, isLoggedIn, userRoles, userGrants };
|
|
52
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FindRequest } from '../api';
|
|
2
|
+
import { MongoFindRequest } from "../api";
|
|
3
|
+
export declare const useMongocampSearch: () => {
|
|
4
|
+
createFindRequest: (collection: string, searchParameter?: MongoFindRequest, rows?: any, actualPage?: number) => FindRequest;
|
|
5
|
+
createSearchParameter: (filter?: object, sort?: object, projection?: object) => MongoFindRequest;
|
|
6
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#app";
|
|
2
|
+
export const useMongocampSearch = () => {
|
|
3
|
+
const config = useRuntimeConfig();
|
|
4
|
+
const createFindRequest = (collection, searchParameter = createSearchParameter(), rows = config.mongocamp?.paginationSize, actualPage = 1) => {
|
|
5
|
+
const result = { collectionName: collection, mongoFindRequest: searchParameter, rowsPerPage: rows, page: actualPage };
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
const createSearchParameter = (filter = {}, sort = {}, projection = {}) => {
|
|
9
|
+
return { filter, sort, projection };
|
|
10
|
+
};
|
|
11
|
+
return { createFindRequest, createSearchParameter };
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMongocampToken: () => any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useCookie, useNuxtApp } from "#app";
|
|
2
|
+
export const useMongocampToken = () => {
|
|
3
|
+
const nuxtApp = useNuxtApp();
|
|
4
|
+
nuxtApp._cookies = nuxtApp._cookies || {};
|
|
5
|
+
if (nuxtApp._cookies.mongocamp_token)
|
|
6
|
+
return nuxtApp._cookies.mongocamp_token;
|
|
7
|
+
const cookie = useCookie("mongocamp_token");
|
|
8
|
+
nuxtApp._cookies.mongocamp_token = cookie;
|
|
9
|
+
return cookie;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMongocampUrl: () => string;
|
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sfxcode/nuxt-mongocamp-server",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/module.mjs",
|
|
9
|
+
"require": "./dist/module.cjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/module.cjs",
|
|
13
|
+
"types": "./dist/types.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@antfu/eslint-config": "^0.27.0",
|
|
19
|
+
"@iconify-json/mdi": "^1.1.33",
|
|
20
|
+
"@nuxt/kit": "^3.0.0-rc.11",
|
|
21
|
+
"@nuxt/module-builder": "latest",
|
|
22
|
+
"@openapitools/openapi-generator-cli": "^2.5.2",
|
|
23
|
+
"@types/node": "^18.7.23",
|
|
24
|
+
"@unocss/nuxt": "^0.45.26",
|
|
25
|
+
"defu": "^6.1.0",
|
|
26
|
+
"jiti": "^1.16.0",
|
|
27
|
+
"nuxt": "^3.0.0-rc.11"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "nuxi dev --port 3333 playground",
|
|
31
|
+
"dev:build": "nuxi build playground",
|
|
32
|
+
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
|
33
|
+
"lint:show": "eslint ./src/runtime",
|
|
34
|
+
"lint:fix": "eslint --fix ./src/runtime",
|
|
35
|
+
"api-codegen": "openapi-generator-cli generate -i http://localhost:3000/docs/docs.yaml -g typescript-fetch -o src/runtime/api --additional-properties=typescriptThreePlus=true,supportsES6=true"
|
|
36
|
+
}
|
|
37
|
+
}
|