@vritti/api-sdk 0.3.13 → 0.3.15
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/catalog-resolver.cjs +128 -22
- package/dist/catalog-resolver.cjs.map +1 -1
- package/dist/catalog-resolver.d.cts +27 -7
- package/dist/catalog-resolver.d.ts +27 -7
- package/dist/catalog-resolver.js +119 -21
- package/dist/catalog-resolver.js.map +1 -1
- package/dist/decorators.cjs +0 -163
- package/dist/decorators.cjs.map +1 -1
- package/dist/decorators.d.cts +1 -10
- package/dist/decorators.d.ts +1 -10
- package/dist/decorators.js +0 -161
- package/dist/decorators.js.map +1 -1
- package/dist/files.cjs +210 -0
- package/dist/files.cjs.map +1 -0
- package/dist/files.d.cts +20 -0
- package/dist/files.d.ts +20 -0
- package/dist/files.js +182 -0
- package/dist/files.js.map +1 -0
- package/dist/license.d.cts +1 -1
- package/dist/license.d.ts +1 -1
- package/dist/{types-CG-Ynwyf.d.cts → types-B7ArIjwo.d.cts} +25 -10
- package/dist/{types-CG-Ynwyf.d.ts → types-B7ArIjwo.d.ts} +25 -10
- package/package.json +11 -1
package/dist/files.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/files/uploaded-file.decorator.ts
|
|
5
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
6
|
+
import { plainToInstance } from "class-transformer";
|
|
7
|
+
import { validate } from "class-validator";
|
|
8
|
+
|
|
9
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
10
|
+
import { HttpStatus } from "@nestjs/common";
|
|
11
|
+
|
|
12
|
+
// src/exceptions/base-field.exception.ts
|
|
13
|
+
import { HttpException } from "@nestjs/common";
|
|
14
|
+
var HttpProblemException = class extends HttpException {
|
|
15
|
+
static {
|
|
16
|
+
__name(this, "HttpProblemException");
|
|
17
|
+
}
|
|
18
|
+
constructor(detailOrOptions, httpStatus) {
|
|
19
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
20
|
+
detail: detailOrOptions
|
|
21
|
+
} : detailOrOptions;
|
|
22
|
+
super({
|
|
23
|
+
type: options.type ?? "about:blank",
|
|
24
|
+
label: options.label,
|
|
25
|
+
detail: options.detail,
|
|
26
|
+
errors: options.errors ?? []
|
|
27
|
+
}, httpStatus);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/exceptions/bad-request.exception.ts
|
|
32
|
+
import { HttpStatus as HttpStatus2 } from "@nestjs/common";
|
|
33
|
+
var BadRequestException = class extends HttpProblemException {
|
|
34
|
+
static {
|
|
35
|
+
__name(this, "BadRequestException");
|
|
36
|
+
}
|
|
37
|
+
constructor(detailOrOptions) {
|
|
38
|
+
super(detailOrOptions ?? "Bad Request", HttpStatus2.BAD_REQUEST);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/exceptions/conflict.exception.ts
|
|
43
|
+
import { HttpStatus as HttpStatus3 } from "@nestjs/common";
|
|
44
|
+
|
|
45
|
+
// src/exceptions/forbidden.exception.ts
|
|
46
|
+
import { HttpStatus as HttpStatus4 } from "@nestjs/common";
|
|
47
|
+
|
|
48
|
+
// src/exceptions/gone.exception.ts
|
|
49
|
+
import { HttpStatus as HttpStatus5 } from "@nestjs/common";
|
|
50
|
+
|
|
51
|
+
// src/exceptions/internal-server-error.exception.ts
|
|
52
|
+
import { HttpStatus as HttpStatus6 } from "@nestjs/common";
|
|
53
|
+
|
|
54
|
+
// src/exceptions/method-not-allowed.exception.ts
|
|
55
|
+
import { HttpStatus as HttpStatus7 } from "@nestjs/common";
|
|
56
|
+
|
|
57
|
+
// src/exceptions/not-acceptable.exception.ts
|
|
58
|
+
import { HttpStatus as HttpStatus8 } from "@nestjs/common";
|
|
59
|
+
|
|
60
|
+
// src/exceptions/not-found.exception.ts
|
|
61
|
+
import { HttpStatus as HttpStatus9 } from "@nestjs/common";
|
|
62
|
+
|
|
63
|
+
// src/exceptions/not-implemented.exception.ts
|
|
64
|
+
import { HttpStatus as HttpStatus10 } from "@nestjs/common";
|
|
65
|
+
|
|
66
|
+
// src/exceptions/payload-too-large.exception.ts
|
|
67
|
+
import { HttpStatus as HttpStatus11 } from "@nestjs/common";
|
|
68
|
+
|
|
69
|
+
// src/exceptions/request-timeout.exception.ts
|
|
70
|
+
import { HttpStatus as HttpStatus12 } from "@nestjs/common";
|
|
71
|
+
|
|
72
|
+
// src/exceptions/service-unavailable.exception.ts
|
|
73
|
+
import { HttpStatus as HttpStatus13 } from "@nestjs/common";
|
|
74
|
+
|
|
75
|
+
// src/exceptions/too-many-requests.exception.ts
|
|
76
|
+
import { HttpStatus as HttpStatus14 } from "@nestjs/common";
|
|
77
|
+
|
|
78
|
+
// src/exceptions/unauthorized.exception.ts
|
|
79
|
+
import { HttpStatus as HttpStatus15 } from "@nestjs/common";
|
|
80
|
+
|
|
81
|
+
// src/exceptions/unprocessable-entity.exception.ts
|
|
82
|
+
import { HttpStatus as HttpStatus16 } from "@nestjs/common";
|
|
83
|
+
|
|
84
|
+
// src/exceptions/unsupported-media-type.exception.ts
|
|
85
|
+
import { HttpStatus as HttpStatus17 } from "@nestjs/common";
|
|
86
|
+
|
|
87
|
+
// src/exceptions/validation.exception.ts
|
|
88
|
+
import { HttpStatus as HttpStatus18 } from "@nestjs/common";
|
|
89
|
+
|
|
90
|
+
// src/files/uploaded-file.decorator.ts
|
|
91
|
+
var PARSED = Symbol("vritti.multipart");
|
|
92
|
+
function readMultipart(request) {
|
|
93
|
+
const cached = request;
|
|
94
|
+
cached[PARSED] ??= (async () => {
|
|
95
|
+
const content = {
|
|
96
|
+
fields: {},
|
|
97
|
+
files: {}
|
|
98
|
+
};
|
|
99
|
+
for await (const part of request.parts()) {
|
|
100
|
+
if (part.type === "file") {
|
|
101
|
+
const file = {
|
|
102
|
+
buffer: await part.toBuffer(),
|
|
103
|
+
filename: part.filename,
|
|
104
|
+
mimetype: part.mimetype
|
|
105
|
+
};
|
|
106
|
+
const existing = content.files[part.fieldname];
|
|
107
|
+
if (existing) existing.push(file);
|
|
108
|
+
else content.files[part.fieldname] = [
|
|
109
|
+
file
|
|
110
|
+
];
|
|
111
|
+
} else {
|
|
112
|
+
content.fields[part.fieldname] = part.value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return content;
|
|
116
|
+
})();
|
|
117
|
+
return cached[PARSED];
|
|
118
|
+
}
|
|
119
|
+
__name(readMultipart, "readMultipart");
|
|
120
|
+
function flatten(files) {
|
|
121
|
+
return Object.values(files).flat();
|
|
122
|
+
}
|
|
123
|
+
__name(flatten, "flatten");
|
|
124
|
+
var UploadedFile = createParamDecorator(async (fieldName, ctx) => {
|
|
125
|
+
const { files } = await readMultipart(ctx.switchToHttp().getRequest());
|
|
126
|
+
const file = (fieldName ? files[fieldName] : flatten(files))?.[0];
|
|
127
|
+
if (!file) {
|
|
128
|
+
const field = fieldName ?? "file";
|
|
129
|
+
throw new BadRequestException({
|
|
130
|
+
label: "File Required",
|
|
131
|
+
detail: `Please attach a file${fieldName ? ` under "${fieldName}"` : ""} to your request.`,
|
|
132
|
+
errors: [
|
|
133
|
+
{
|
|
134
|
+
field,
|
|
135
|
+
message: "File required"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return file;
|
|
141
|
+
});
|
|
142
|
+
var UploadedFiles = createParamDecorator(async (fieldName, ctx) => {
|
|
143
|
+
const { files } = await readMultipart(ctx.switchToHttp().getRequest());
|
|
144
|
+
if (!fieldName) return files;
|
|
145
|
+
const matched = files[fieldName] ?? [];
|
|
146
|
+
if (matched.length === 0) {
|
|
147
|
+
throw new BadRequestException({
|
|
148
|
+
label: "Files Required",
|
|
149
|
+
detail: `Please attach at least one file under "${fieldName}" to your request.`,
|
|
150
|
+
errors: [
|
|
151
|
+
{
|
|
152
|
+
field: fieldName,
|
|
153
|
+
message: "At least one file is required"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return matched;
|
|
159
|
+
});
|
|
160
|
+
var MultipartDto = createParamDecorator(async (dtoClass, ctx) => {
|
|
161
|
+
const { fields } = await readMultipart(ctx.switchToHttp().getRequest());
|
|
162
|
+
const dto = plainToInstance(dtoClass, fields);
|
|
163
|
+
const errors = await validate(dto);
|
|
164
|
+
if (errors.length > 0) {
|
|
165
|
+
throw new BadRequestException({
|
|
166
|
+
label: "Validation Failed",
|
|
167
|
+
detail: "One or more fields are invalid.",
|
|
168
|
+
errors: errors.map((e) => ({
|
|
169
|
+
field: e.property,
|
|
170
|
+
message: Object.values(e.constraints ?? {})[0] ?? "Invalid value"
|
|
171
|
+
}))
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return dto;
|
|
175
|
+
});
|
|
176
|
+
export {
|
|
177
|
+
MultipartDto,
|
|
178
|
+
UploadedFile,
|
|
179
|
+
UploadedFiles,
|
|
180
|
+
readMultipart
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/files/uploaded-file.decorator.ts","../src/exceptions/bad-gateway.exception.ts","../src/exceptions/base-field.exception.ts","../src/exceptions/bad-request.exception.ts","../src/exceptions/conflict.exception.ts","../src/exceptions/forbidden.exception.ts","../src/exceptions/gone.exception.ts","../src/exceptions/internal-server-error.exception.ts","../src/exceptions/method-not-allowed.exception.ts","../src/exceptions/not-acceptable.exception.ts","../src/exceptions/not-found.exception.ts","../src/exceptions/not-implemented.exception.ts","../src/exceptions/payload-too-large.exception.ts","../src/exceptions/request-timeout.exception.ts","../src/exceptions/service-unavailable.exception.ts","../src/exceptions/too-many-requests.exception.ts","../src/exceptions/unauthorized.exception.ts","../src/exceptions/unprocessable-entity.exception.ts","../src/exceptions/unsupported-media-type.exception.ts","../src/exceptions/validation.exception.ts"],"sourcesContent":["import type {} from '@fastify/multipart';\nimport { createParamDecorator, type ExecutionContext } from '@nestjs/common';\nimport { type ClassConstructor, plainToInstance } from 'class-transformer';\nimport { validate } from 'class-validator';\nimport type { FastifyRequest } from 'fastify';\nimport { BadRequestException } from '../exceptions';\n\nexport interface UploadedFileResult {\n buffer: Buffer;\n filename: string;\n mimetype: string;\n}\n\nexport type UploadedFileMap = Record<string, UploadedFileResult[]>;\n\nexport interface MultipartContent {\n fields: Record<string, unknown>;\n files: UploadedFileMap;\n}\n\nconst PARSED = Symbol('vritti.multipart');\n\ntype ParsedRequest = FastifyRequest & { [PARSED]?: Promise<MultipartContent> };\n\n// Reads the whole multipart body once and caches it — the part stream cannot be walked twice\nexport function readMultipart(request: FastifyRequest): Promise<MultipartContent> {\n const cached = request as ParsedRequest;\n cached[PARSED] ??= (async () => {\n const content: MultipartContent = { fields: {}, files: {} };\n for await (const part of request.parts()) {\n if (part.type === 'file') {\n const file = { buffer: await part.toBuffer(), filename: part.filename, mimetype: part.mimetype };\n const existing = content.files[part.fieldname];\n if (existing) existing.push(file);\n else content.files[part.fieldname] = [file];\n } else {\n content.fields[part.fieldname] = part.value;\n }\n }\n return content;\n })();\n return cached[PARSED];\n}\n\nfunction flatten(files: Record<string, UploadedFileResult[]>): UploadedFileResult[] {\n return Object.values(files).flat();\n}\n\n// The single file sent under `fieldName`, or the only file on the request; throws when absent\nexport const UploadedFile = createParamDecorator(\n async (fieldName: string | undefined, ctx: ExecutionContext): Promise<UploadedFileResult> => {\n const { files } = await readMultipart(ctx.switchToHttp().getRequest<FastifyRequest>());\n const file = (fieldName ? files[fieldName] : flatten(files))?.[0];\n\n if (!file) {\n const field = fieldName ?? 'file';\n throw new BadRequestException({\n label: 'File Required',\n detail: `Please attach a file${fieldName ? ` under \"${fieldName}\"` : ''} to your request.`,\n errors: [{ field, message: 'File required' }],\n });\n }\n return file;\n },\n);\n\n// Every file under `fieldName` (throws when none), or with no name every file keyed by field name (never throws)\nexport const UploadedFiles = createParamDecorator(\n async (\n fieldName: string | undefined,\n ctx: ExecutionContext,\n ): Promise<UploadedFileResult[] | Record<string, UploadedFileResult[]>> => {\n const { files } = await readMultipart(ctx.switchToHttp().getRequest<FastifyRequest>());\n if (!fieldName) return files;\n\n const matched = files[fieldName] ?? [];\n if (matched.length === 0) {\n throw new BadRequestException({\n label: 'Files Required',\n detail: `Please attach at least one file under \"${fieldName}\" to your request.`,\n errors: [{ field: fieldName, message: 'At least one file is required' }],\n });\n }\n return matched;\n },\n);\n\n// The request's text fields validated into `dto`, for a multipart form whose body cannot reach @Body() —\n// fastify only surfaces fields while walking the parts, so request.body is empty without attachFieldsToBody.\nexport const MultipartDto = createParamDecorator(\n async <T extends object>(dtoClass: ClassConstructor<T>, ctx: ExecutionContext): Promise<T> => {\n const { fields } = await readMultipart(ctx.switchToHttp().getRequest<FastifyRequest>());\n const dto = plainToInstance(dtoClass, fields);\n const errors = await validate(dto as object);\n\n if (errors.length > 0) {\n throw new BadRequestException({\n label: 'Validation Failed',\n detail: 'One or more fields are invalid.',\n errors: errors.map((e) => ({\n field: e.property,\n message: Object.values(e.constraints ?? {})[0] ?? 'Invalid value',\n })),\n });\n }\n return dto;\n },\n);\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class BadGatewayException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Bad Gateway', HttpStatus.BAD_GATEWAY);\n }\n}\n","import { HttpException, HttpStatus } from '@nestjs/common';\nimport type { FieldError } from '../types/error-response.types';\n\n// Re-export FieldError for backwards compatibility\nexport type { FieldError } from '../types/error-response.types';\n\nexport interface ProblemOptions {\n type?: string;\n label?: string;\n detail?: string;\n errors?: FieldError[];\n}\n\nexport abstract class HttpProblemException extends HttpException {\n constructor(detailOrOptions: string | ProblemOptions, httpStatus: HttpStatus) {\n const options = typeof detailOrOptions === 'string' ? { detail: detailOrOptions } : detailOrOptions;\n\n super(\n {\n type: options.type ?? 'about:blank',\n label: options.label,\n detail: options.detail,\n errors: options.errors ?? [],\n },\n httpStatus,\n );\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class BadRequestException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Bad Request', HttpStatus.BAD_REQUEST);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ConflictException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Conflict', HttpStatus.CONFLICT);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ForbiddenException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Forbidden', HttpStatus.FORBIDDEN);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class GoneException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Gone', HttpStatus.GONE);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class InternalServerErrorException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Internal Server Error', HttpStatus.INTERNAL_SERVER_ERROR);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class MethodNotAllowedException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Method Not Allowed', HttpStatus.METHOD_NOT_ALLOWED);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class NotAcceptableException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Not Acceptable', HttpStatus.NOT_ACCEPTABLE);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class NotFoundException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Not Found', HttpStatus.NOT_FOUND);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class NotImplementedException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Not Implemented', HttpStatus.NOT_IMPLEMENTED);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class PayloadTooLargeException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Payload Too Large', HttpStatus.PAYLOAD_TOO_LARGE);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class RequestTimeoutException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Request Timeout', HttpStatus.REQUEST_TIMEOUT);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ServiceUnavailableException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Service Unavailable', HttpStatus.SERVICE_UNAVAILABLE);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class TooManyRequestsException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Too Many Requests', HttpStatus.TOO_MANY_REQUESTS);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class UnauthorizedException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Unauthorized', HttpStatus.UNAUTHORIZED);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class UnprocessableEntityException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Unprocessable Entity', HttpStatus.UNPROCESSABLE_ENTITY);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class UnsupportedMediaTypeException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Unsupported Media Type', HttpStatus.UNSUPPORTED_MEDIA_TYPE);\n }\n}\n","import { HttpStatus } from '@nestjs/common';\nimport { HttpProblemException, type ProblemOptions } from './base-field.exception';\n\nexport class ValidationException extends HttpProblemException {\n constructor(detailOrOptions?: string | ProblemOptions) {\n super(detailOrOptions ?? 'Validation Failed', HttpStatus.UNPROCESSABLE_ENTITY);\n }\n}\n"],"mappings":";;;;AACA,SAASA,4BAAmD;AAC5D,SAAgCC,uBAAuB;AACvD,SAASC,gBAAgB;;;ACHzB,SAASC,kBAAkB;;;ACA3B,SAASC,qBAAiC;AAanC,IAAeC,uBAAf,cAA4CC,cAAAA;EAbnD,OAamDA;;;EACjD,YAAYC,iBAA0CC,YAAwB;AAC5E,UAAMC,UAAU,OAAOF,oBAAoB,WAAW;MAAEG,QAAQH;IAAgB,IAAIA;AAEpF,UACE;MACEI,MAAMF,QAAQE,QAAQ;MACtBC,OAAOH,QAAQG;MACfF,QAAQD,QAAQC;MAChBG,QAAQJ,QAAQI,UAAU,CAAA;IAC5B,GACAL,UAAAA;EAEJ;AACF;;;AC3BA,SAASM,c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AASF,GAAAA;AAE9B,MAAIP,OAAOI,SAAS,GAAG;AACrB,UAAM,IAAIP,oBAAoB;MAC5BC,OAAO;MACPC,QAAQ;MACRC,QAAQA,OAAOU,IAAI,CAACC,OAAO;QACzBf,OAAOe,EAAEC;QACTX,SAASd,OAAOC,OAAOuB,EAAEE,eAAe,CAAC,CAAA,EAAG,CAAA,KAAM;MACpD,EAAA;IACF,CAAA;EACF;AACA,SAAON;AACT,CAAA;","names":["createParamDecorator","plainToInstance","validate","HttpStatus","HttpException","HttpProblemException","HttpException","detailOrOptions","httpStatus","options","detail","type","label","errors","HttpStatus","BadRequestException","HttpProblemException","detailOrOptions","HttpStatus","BAD_REQUEST","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","HttpStatus","PARSED","Symbol","readMultipart","request","cached","content","fields","files","part","parts","type","file","buffer","toBuffer","filename","mimetype","existing","fieldname","push","value","flatten","Object","values","flat","UploadedFile","createParamDecorator","fieldName","ctx","switchToHttp","getRequest","field","BadRequestException","label","detail","errors","message","UploadedFiles","matched","length","MultipartDto","dtoClass","dto","plainToInstance","validate","map","e","property","constraints"]}
|
package/dist/license.d.cts
CHANGED
package/dist/license.d.ts
CHANGED
|
@@ -2,24 +2,38 @@
|
|
|
2
2
|
* The surfaces a permission can be granted on.
|
|
3
3
|
*
|
|
4
4
|
* `web` and `mobile` are UI buckets: a feature reaches them through a microfrontend, and a grant
|
|
5
|
-
* there means a person can operate it on that surface. `
|
|
6
|
-
*
|
|
7
|
-
* neither to be reachable
|
|
5
|
+
* there means a person can operate it on that surface. `graphql` and `http` are not UIs at all —
|
|
6
|
+
* each is an API surface a credential signs its own requests against, so they have no
|
|
7
|
+
* microfrontend and no route, and a feature needs neither to be reachable on one.
|
|
8
8
|
*
|
|
9
|
-
* Keeping
|
|
10
|
-
* feature locks and permission prerequisites bind an API client exactly as they bind a person.
|
|
9
|
+
* Keeping the API buckets in the same algebra rather than beside it is what lets plan entitlement,
|
|
10
|
+
* node feature locks and permission prerequisites bind an API client exactly as they bind a person.
|
|
11
|
+
* One bucket per surface is what lets a plan entitle GraphQL and HTTP access independently.
|
|
11
12
|
*/
|
|
12
|
-
type PlatformBucket = 'web' | 'mobile' | '
|
|
13
|
+
type PlatformBucket = 'web' | 'mobile' | 'graphql' | 'http';
|
|
13
14
|
declare const PLATFORMS: PlatformBucket[];
|
|
15
|
+
/** Buckets that reach their feature through a microfrontend, and so require one to resolve. */
|
|
16
|
+
type UiPlatformBucket = 'web' | 'mobile';
|
|
17
|
+
declare const UI_PLATFORMS: UiPlatformBucket[];
|
|
18
|
+
declare const API_SURFACES: readonly ["GRAPHQL", "HTTP"];
|
|
19
|
+
type ApiSurface = (typeof API_SURFACES)[number];
|
|
20
|
+
/** Buckets that admit an API credential rather than a person — exactly one per surface. */
|
|
21
|
+
type ApiBucket = Exclude<PlatformBucket, UiPlatformBucket>;
|
|
22
|
+
declare const API_BUCKETS: ApiBucket[];
|
|
23
|
+
declare const SURFACE_BY_BUCKET: Record<ApiBucket, ApiSurface>;
|
|
24
|
+
declare const BUCKET_BY_SURFACE: Record<ApiSurface, ApiBucket>;
|
|
25
|
+
declare function isApiBucket(bucket: PlatformBucket): bucket is ApiBucket;
|
|
14
26
|
interface PlatformCodes {
|
|
15
27
|
web?: string[];
|
|
16
28
|
mobile?: string[];
|
|
17
|
-
|
|
29
|
+
graphql?: string[];
|
|
30
|
+
http?: string[];
|
|
18
31
|
}
|
|
19
32
|
interface PlatformDenyCodes {
|
|
20
33
|
web?: string[] | null;
|
|
21
34
|
mobile?: string[] | null;
|
|
22
|
-
|
|
35
|
+
graphql?: string[] | null;
|
|
36
|
+
http?: string[] | null;
|
|
23
37
|
}
|
|
24
38
|
type FeatureUnlocks = Record<string, PlatformCodes>;
|
|
25
39
|
type FeatureLocks = Record<string, PlatformDenyCodes>;
|
|
@@ -66,6 +80,7 @@ interface SnapshotFeature {
|
|
|
66
80
|
permissions: SnapshotPermission[];
|
|
67
81
|
microfrontends: SnapshotMicrofrontends;
|
|
68
82
|
requiredServices?: ServiceCode[];
|
|
83
|
+
apiSurfaces?: ApiSurface[];
|
|
69
84
|
}
|
|
70
85
|
interface SnapshotAppFeatureRef {
|
|
71
86
|
code: string;
|
|
@@ -116,7 +131,7 @@ interface VersionSnapshot {
|
|
|
116
131
|
businesses: Record<string, SnapshotBusiness>;
|
|
117
132
|
}
|
|
118
133
|
declare function snapshotFeatureKey(code: string, scope: ScopeType): string;
|
|
119
|
-
declare const SNAPSHOT_SCHEMA_VERSION =
|
|
134
|
+
declare const SNAPSHOT_SCHEMA_VERSION = 4;
|
|
120
135
|
type LockReason = 'PLAN' | 'SITE' | 'SERVICE';
|
|
121
136
|
interface CatalogPermission {
|
|
122
137
|
code: string;
|
|
@@ -154,4 +169,4 @@ interface FeatureCatalogEntry {
|
|
|
154
169
|
}
|
|
155
170
|
type RoleItem = SnapshotRoleTemplate;
|
|
156
171
|
|
|
157
|
-
export { type
|
|
172
|
+
export { type ApiSurface as A, BUCKET_BY_SURFACE as B, type CatalogPermission as C, SURFACE_BY_BUCKET as D, snapshotFeatureKey as E, type FeatureCatalogEntry as F, type UiPlatformBucket as G, type VocabularyEntry as H, type LockReason as L, type PlatformBucket as P, type RoleItem as R, type SiteFeatureLocks as S, UI_PLATFORMS as U, type VersionSnapshot as V, type SiteType as a, type ScopeType as b, type ServiceCode as c, type SnapshotFeature as d, type PlatformCodes as e, type PlatformDenyCodes as f, type FeatureUnlocks as g, API_BUCKETS as h, API_SURFACES as i, type ApiBucket as j, type BusinessVocabulary as k, type FeatureLocks as l, isApiBucket as m, PLATFORMS as n, SERVICE_CODES as o, SITE_TYPES as p, SNAPSHOT_SCHEMA_VERSION as q, type SnapshotApp as r, type SnapshotAppFeatureRef as s, type SnapshotBusiness as t, type SnapshotMicrofrontendMobile as u, type SnapshotMicrofrontends as v, type SnapshotMicrofrontendWeb as w, type SnapshotPermission as x, type SnapshotPlan as y, type SnapshotRoleTemplate as z };
|
|
@@ -2,24 +2,38 @@
|
|
|
2
2
|
* The surfaces a permission can be granted on.
|
|
3
3
|
*
|
|
4
4
|
* `web` and `mobile` are UI buckets: a feature reaches them through a microfrontend, and a grant
|
|
5
|
-
* there means a person can operate it on that surface. `
|
|
6
|
-
*
|
|
7
|
-
* neither to be reachable
|
|
5
|
+
* there means a person can operate it on that surface. `graphql` and `http` are not UIs at all —
|
|
6
|
+
* each is an API surface a credential signs its own requests against, so they have no
|
|
7
|
+
* microfrontend and no route, and a feature needs neither to be reachable on one.
|
|
8
8
|
*
|
|
9
|
-
* Keeping
|
|
10
|
-
* feature locks and permission prerequisites bind an API client exactly as they bind a person.
|
|
9
|
+
* Keeping the API buckets in the same algebra rather than beside it is what lets plan entitlement,
|
|
10
|
+
* node feature locks and permission prerequisites bind an API client exactly as they bind a person.
|
|
11
|
+
* One bucket per surface is what lets a plan entitle GraphQL and HTTP access independently.
|
|
11
12
|
*/
|
|
12
|
-
type PlatformBucket = 'web' | 'mobile' | '
|
|
13
|
+
type PlatformBucket = 'web' | 'mobile' | 'graphql' | 'http';
|
|
13
14
|
declare const PLATFORMS: PlatformBucket[];
|
|
15
|
+
/** Buckets that reach their feature through a microfrontend, and so require one to resolve. */
|
|
16
|
+
type UiPlatformBucket = 'web' | 'mobile';
|
|
17
|
+
declare const UI_PLATFORMS: UiPlatformBucket[];
|
|
18
|
+
declare const API_SURFACES: readonly ["GRAPHQL", "HTTP"];
|
|
19
|
+
type ApiSurface = (typeof API_SURFACES)[number];
|
|
20
|
+
/** Buckets that admit an API credential rather than a person — exactly one per surface. */
|
|
21
|
+
type ApiBucket = Exclude<PlatformBucket, UiPlatformBucket>;
|
|
22
|
+
declare const API_BUCKETS: ApiBucket[];
|
|
23
|
+
declare const SURFACE_BY_BUCKET: Record<ApiBucket, ApiSurface>;
|
|
24
|
+
declare const BUCKET_BY_SURFACE: Record<ApiSurface, ApiBucket>;
|
|
25
|
+
declare function isApiBucket(bucket: PlatformBucket): bucket is ApiBucket;
|
|
14
26
|
interface PlatformCodes {
|
|
15
27
|
web?: string[];
|
|
16
28
|
mobile?: string[];
|
|
17
|
-
|
|
29
|
+
graphql?: string[];
|
|
30
|
+
http?: string[];
|
|
18
31
|
}
|
|
19
32
|
interface PlatformDenyCodes {
|
|
20
33
|
web?: string[] | null;
|
|
21
34
|
mobile?: string[] | null;
|
|
22
|
-
|
|
35
|
+
graphql?: string[] | null;
|
|
36
|
+
http?: string[] | null;
|
|
23
37
|
}
|
|
24
38
|
type FeatureUnlocks = Record<string, PlatformCodes>;
|
|
25
39
|
type FeatureLocks = Record<string, PlatformDenyCodes>;
|
|
@@ -66,6 +80,7 @@ interface SnapshotFeature {
|
|
|
66
80
|
permissions: SnapshotPermission[];
|
|
67
81
|
microfrontends: SnapshotMicrofrontends;
|
|
68
82
|
requiredServices?: ServiceCode[];
|
|
83
|
+
apiSurfaces?: ApiSurface[];
|
|
69
84
|
}
|
|
70
85
|
interface SnapshotAppFeatureRef {
|
|
71
86
|
code: string;
|
|
@@ -116,7 +131,7 @@ interface VersionSnapshot {
|
|
|
116
131
|
businesses: Record<string, SnapshotBusiness>;
|
|
117
132
|
}
|
|
118
133
|
declare function snapshotFeatureKey(code: string, scope: ScopeType): string;
|
|
119
|
-
declare const SNAPSHOT_SCHEMA_VERSION =
|
|
134
|
+
declare const SNAPSHOT_SCHEMA_VERSION = 4;
|
|
120
135
|
type LockReason = 'PLAN' | 'SITE' | 'SERVICE';
|
|
121
136
|
interface CatalogPermission {
|
|
122
137
|
code: string;
|
|
@@ -154,4 +169,4 @@ interface FeatureCatalogEntry {
|
|
|
154
169
|
}
|
|
155
170
|
type RoleItem = SnapshotRoleTemplate;
|
|
156
171
|
|
|
157
|
-
export { type
|
|
172
|
+
export { type ApiSurface as A, BUCKET_BY_SURFACE as B, type CatalogPermission as C, SURFACE_BY_BUCKET as D, snapshotFeatureKey as E, type FeatureCatalogEntry as F, type UiPlatformBucket as G, type VocabularyEntry as H, type LockReason as L, type PlatformBucket as P, type RoleItem as R, type SiteFeatureLocks as S, UI_PLATFORMS as U, type VersionSnapshot as V, type SiteType as a, type ScopeType as b, type ServiceCode as c, type SnapshotFeature as d, type PlatformCodes as e, type PlatformDenyCodes as f, type FeatureUnlocks as g, API_BUCKETS as h, API_SURFACES as i, type ApiBucket as j, type BusinessVocabulary as k, type FeatureLocks as l, isApiBucket as m, PLATFORMS as n, SERVICE_CODES as o, SITE_TYPES as p, SNAPSHOT_SCHEMA_VERSION as q, type SnapshotApp as r, type SnapshotAppFeatureRef as s, type SnapshotBusiness as t, type SnapshotMicrofrontendMobile as u, type SnapshotMicrofrontends as v, type SnapshotMicrofrontendWeb as w, type SnapshotPermission as x, type SnapshotPlan as y, type SnapshotRoleTemplate as z };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vritti/api-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.15",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -236,6 +236,16 @@
|
|
|
236
236
|
"default": "./dist/decorators.cjs"
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
|
+
"./files": {
|
|
240
|
+
"import": {
|
|
241
|
+
"types": "./dist/files.d.ts",
|
|
242
|
+
"default": "./dist/files.js"
|
|
243
|
+
},
|
|
244
|
+
"require": {
|
|
245
|
+
"types": "./dist/files.d.cts",
|
|
246
|
+
"default": "./dist/files.cjs"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
239
249
|
"./filters": {
|
|
240
250
|
"import": {
|
|
241
251
|
"types": "./dist/filters.d.ts",
|