sloth-d2c-node 0.0.1-beta44

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 (36) hide show
  1. package/README.md +2 -0
  2. package/dist/main.d.ts +1 -0
  3. package/dist/main.js +76 -0
  4. package/dist/main.js.map +1 -0
  5. package/dist/modules/app.controller.d.ts +20 -0
  6. package/dist/modules/app.controller.js +122 -0
  7. package/dist/modules/app.controller.js.map +1 -0
  8. package/dist/modules/app.module.d.ts +2 -0
  9. package/dist/modules/app.module.js +25 -0
  10. package/dist/modules/app.module.js.map +1 -0
  11. package/dist/modules/app.service.d.ts +3 -0
  12. package/dist/modules/app.service.js +20 -0
  13. package/dist/modules/app.service.js.map +1 -0
  14. package/dist/modules/d2c/d2c.controller.d.ts +23 -0
  15. package/dist/modules/d2c/d2c.controller.js +108 -0
  16. package/dist/modules/d2c/d2c.controller.js.map +1 -0
  17. package/dist/modules/d2c/d2c.module.d.ts +2 -0
  18. package/dist/modules/d2c/d2c.module.js +27 -0
  19. package/dist/modules/d2c/d2c.module.js.map +1 -0
  20. package/dist/modules/d2c/d2c.service.d.ts +12 -0
  21. package/dist/modules/d2c/d2c.service.js +40 -0
  22. package/dist/modules/d2c/d2c.service.js.map +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -0
  24. package/dist/utils/d2c-convert.d.ts +40 -0
  25. package/dist/utils/d2c-convert.js +184 -0
  26. package/dist/utils/d2c-convert.js.map +1 -0
  27. package/dist/utils/figma.d.ts +7 -0
  28. package/dist/utils/figma.js +47 -0
  29. package/dist/utils/figma.js.map +1 -0
  30. package/dist/utils/index.d.ts +27 -0
  31. package/dist/utils/index.js +285 -0
  32. package/dist/utils/index.js.map +1 -0
  33. package/dist/utils/webpack-substitutions.d.ts +1 -0
  34. package/dist/utils/webpack-substitutions.js +135 -0
  35. package/dist/utils/webpack-substitutions.js.map +1 -0
  36. package/package.json +112 -0
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # apps/node
2
+ 转码能力的node服务,需在apps/figma中执行pnpm dev:lib:node,然后再pnpm dev启动调试,
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const common_1 = require("@nestjs/common");
40
+ const core_1 = require("@nestjs/core");
41
+ const bodyParser = __importStar(require("body-parser"));
42
+ const cookie_parser_1 = __importDefault(require("cookie-parser"));
43
+ const path_1 = require("path");
44
+ const dotenv = __importStar(require("dotenv"));
45
+ const app_module_1 = require("./modules/app.module");
46
+ async function bootstrap() {
47
+ if (process.env.NODE_ENV === 'development') {
48
+ dotenv.config({ path: '.env.development' });
49
+ }
50
+ else if (process.env.NODE_ENV === 'production') {
51
+ dotenv.config({ path: '.env.production' });
52
+ }
53
+ else {
54
+ dotenv.config();
55
+ }
56
+ const app = await core_1.NestFactory.create(app_module_1.AppModule);
57
+ const port = process.env.NODE_PORT || 8999;
58
+ app.useStaticAssets((0, path_1.resolve)('./public'));
59
+ app.setBaseViewsDir((0, path_1.join)(__dirname, '../views'));
60
+ app.setViewEngine('hbs');
61
+ const corsOptions = {
62
+ origin: '*',
63
+ credentials: true,
64
+ methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
65
+ maxAge: 24 * 60 * 60 * 5,
66
+ };
67
+ app.enableCors(corsOptions);
68
+ app.useGlobalPipes(new common_1.ValidationPipe());
69
+ console.log('cookieParser', cookie_parser_1.default);
70
+ app.use((0, cookie_parser_1.default)());
71
+ app.use(bodyParser.json({ limit: '50mb' }));
72
+ app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
73
+ await app.listen(port, () => console.log(`📢 Server starting on: http://localhost:${port}/ ⚡️`));
74
+ }
75
+ bootstrap();
76
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,2CAA+C;AAE/C,uCAA0C;AAE1C,wDAAyC;AACzC,kEAAwC;AACxC,+BAAoC;AACpC,+CAAgC;AAChC,qDAAgD;AAEhD,KAAK,UAAU,SAAS;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAA;IAC7C,CAAC;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,MAAM,EAAE,CAAA;IACjB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAyB,sBAAS,CAAC,CAAA;IACvE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,CAAA;IAE1C,GAAG,CAAC,eAAe,CAAC,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC,CAAA;IACxC,GAAG,CAAC,eAAe,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAA;IAChD,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAExB,MAAM,WAAW,GAAgB;QAC/B,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;QAC7D,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;KACzB,CAAA;IAGD,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;IAE3B,GAAG,CAAC,cAAc,CAAC,IAAI,uBAAc,EAAE,CAAC,CAAA;IAExC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,uBAAY,CAAC,CAAC;IAC1C,GAAG,CAAC,GAAG,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAA;IAIvB,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAC3C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAEjE,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,2CAA2C,IAAI,MAAM,CAAC,CAAC,CAAA;AAClG,CAAC;AACD,SAAS,EAAE,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { Response as Res } from 'express';
2
+ import { AppService } from './app.service';
3
+ export declare class AppController {
4
+ private readonly appService;
5
+ constructor(appService: AppService);
6
+ getHello(): {
7
+ message: string;
8
+ };
9
+ getUtilityCss(): string;
10
+ health(): Promise<{
11
+ code: number;
12
+ msg: string;
13
+ data: {};
14
+ }>;
15
+ prometheus(res: Res): Promise<Res<any, Record<string, any>> | {
16
+ code: number;
17
+ msg: any;
18
+ data: {};
19
+ }>;
20
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.AppController = void 0;
49
+ const common_1 = require("@nestjs/common");
50
+ const client = __importStar(require("prom-client"));
51
+ const app_service_1 = require("./app.service");
52
+ const register = new client.Registry();
53
+ register.setDefaultLabels({
54
+ app: 'nodejs-musicaian-d2c-server',
55
+ });
56
+ client.collectDefaultMetrics({
57
+ register,
58
+ });
59
+ let AppController = class AppController {
60
+ constructor(appService) {
61
+ this.appService = appService;
62
+ }
63
+ getHello() {
64
+ return { message: 'Hello world!' };
65
+ }
66
+ getUtilityCss() {
67
+ return 'utility-css';
68
+ }
69
+ async health() {
70
+ return {
71
+ code: 0,
72
+ msg: 'is ok',
73
+ data: {},
74
+ };
75
+ }
76
+ async prometheus(res) {
77
+ try {
78
+ const metrics = await register.metrics();
79
+ res.set('Content-Type', register.contentType);
80
+ res.send(metrics);
81
+ return res;
82
+ }
83
+ catch (e) {
84
+ return {
85
+ code: 500,
86
+ msg: e.message || 'server is error',
87
+ data: {},
88
+ };
89
+ }
90
+ }
91
+ };
92
+ exports.AppController = AppController;
93
+ __decorate([
94
+ (0, common_1.Get)(),
95
+ __metadata("design:type", Function),
96
+ __metadata("design:paramtypes", []),
97
+ __metadata("design:returntype", void 0)
98
+ ], AppController.prototype, "getHello", null);
99
+ __decorate([
100
+ (0, common_1.Get)('/utility-css'),
101
+ __metadata("design:type", Function),
102
+ __metadata("design:paramtypes", []),
103
+ __metadata("design:returntype", void 0)
104
+ ], AppController.prototype, "getUtilityCss", null);
105
+ __decorate([
106
+ (0, common_1.Get)('health'),
107
+ __metadata("design:type", Function),
108
+ __metadata("design:paramtypes", []),
109
+ __metadata("design:returntype", Promise)
110
+ ], AppController.prototype, "health", null);
111
+ __decorate([
112
+ (0, common_1.Get)('actuator/prometheus'),
113
+ __param(0, (0, common_1.Response)()),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", [Object]),
116
+ __metadata("design:returntype", Promise)
117
+ ], AppController.prototype, "prometheus", null);
118
+ exports.AppController = AppController = __decorate([
119
+ (0, common_1.Controller)(),
120
+ __metadata("design:paramtypes", [app_service_1.AppService])
121
+ ], AppController);
122
+ //# sourceMappingURL=app.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../src/modules/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,2CAA0D;AAE1D,oDAAqC;AACrC,+CAA0C;AAE1C,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAA;AACtC,QAAQ,CAAC,gBAAgB,CAAC;IACxB,GAAG,EAAE,6BAA6B;CACnC,CAAC,CAAA;AACF,MAAM,CAAC,qBAAqB,CAAC;IAC3B,QAAQ;CACT,CAAC,CAAA;AAGK,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,CAAA;IACpC,CAAC;IAGD,aAAa;QACX,OAAO,aAAa,CAAA;IACtB,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM;QACV,OAAO;YACL,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,OAAO;YACZ,IAAI,EAAE,EAAE;SACT,CAAA;IACH,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CAAa,GAAQ;QACnC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAA;YACxC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;YAC7C,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACjB,OAAO,GAAG,CAAA;QACZ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO;gBACL,IAAI,EAAE,GAAG;gBACT,GAAG,EAAE,CAAC,CAAC,OAAO,IAAI,iBAAiB;gBACnC,IAAI,EAAE,EAAE;aACT,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AArCY,sCAAa;AAIxB;IADC,IAAA,YAAG,GAAE;;;;6CAGL;AAGD;IADC,IAAA,YAAG,EAAC,cAAc,CAAC;;;;kDAGnB;AAGK;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;2CAOb;AAGK;IADL,IAAA,YAAG,EAAC,qBAAqB,CAAC;IACT,WAAA,IAAA,iBAAQ,GAAE,CAAA;;;;+CAa3B;wBApCU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAqCzB"}
@@ -0,0 +1,2 @@
1
+ export declare class AppModule {
2
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const config_1 = require("@nestjs/config");
12
+ const app_controller_1 = require("./app.controller");
13
+ const app_service_1 = require("./app.service");
14
+ const d2c_module_1 = require("./d2c/d2c.module");
15
+ let AppModule = class AppModule {
16
+ };
17
+ exports.AppModule = AppModule;
18
+ exports.AppModule = AppModule = __decorate([
19
+ (0, common_1.Module)({
20
+ imports: [config_1.ConfigModule.forRoot(), d2c_module_1.D2CModule],
21
+ controllers: [app_controller_1.AppController],
22
+ providers: [app_service_1.AppService],
23
+ })
24
+ ], AppModule);
25
+ //# sourceMappingURL=app.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/modules/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuC;AACvC,2CAA6C;AAC7C,qDAAgD;AAChD,+CAA0C;AAC1C,iDAA4C;AAMrC,IAAM,SAAS,GAAf,MAAM,SAAS;CACrB,CAAA;AADY,8BAAS;oBAAT,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAY,CAAC,OAAO,EAAE,EAAE,sBAAS,CAAC;QAC5C,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CACrB"}
@@ -0,0 +1,3 @@
1
+ export declare class AppService {
2
+ getHello(): string;
3
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AppService = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let AppService = class AppService {
12
+ getHello() {
13
+ return 'Hello World!';
14
+ }
15
+ };
16
+ exports.AppService = AppService;
17
+ exports.AppService = AppService = __decorate([
18
+ (0, common_1.Injectable)()
19
+ ], AppService);
20
+ //# sourceMappingURL=app.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../../src/modules/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2C;AAGpC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAA;IACvB,CAAC;CACF,CAAA;AAJY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB"}
@@ -0,0 +1,23 @@
1
+ import { D2CService } from './d2c.service';
2
+ declare class ConvertDto {
3
+ fileKey: string;
4
+ nodeId: string;
5
+ depth: number;
6
+ type: string;
7
+ config: any;
8
+ aiDerivedGrouping: any;
9
+ }
10
+ export declare class D2CController {
11
+ private readonly d2cService;
12
+ constructor(d2cService: D2CService);
13
+ convert(convertDto: ConvertDto, figmaToken: string): Promise<{
14
+ code: number;
15
+ data: {
16
+ code: string;
17
+ imageMap: any;
18
+ rootImage: string;
19
+ };
20
+ }>;
21
+ download(fileKey: string, nodeId: string, figmaToken: string): Promise<any>;
22
+ }
23
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.D2CController = void 0;
49
+ const common_1 = require("@nestjs/common");
50
+ const d2c_service_1 = require("./d2c.service");
51
+ const fs = __importStar(require("fs"));
52
+ const flatted = require('flatted');
53
+ class ConvertDto {
54
+ }
55
+ let D2CController = class D2CController {
56
+ constructor(d2cService) {
57
+ this.d2cService = d2cService;
58
+ }
59
+ async convert(convertDto, figmaToken) {
60
+ const { fileKey, nodeId, depth, type, config } = convertDto;
61
+ const { code, imageMap, rootImage } = await this.d2cService.convert({
62
+ fileKey,
63
+ nodeId,
64
+ depth,
65
+ figmaToken,
66
+ type,
67
+ config,
68
+ });
69
+ fs.writeFileSync('mcp.html', code);
70
+ const data = flatted.stringify(code);
71
+ console.log('before return', data);
72
+ return {
73
+ code: 0,
74
+ data: {
75
+ code,
76
+ imageMap,
77
+ rootImage,
78
+ },
79
+ };
80
+ }
81
+ async download(fileKey, nodeId, figmaToken) {
82
+ const res = await this.d2cService.download({ fileKey, nodeId, figmaToken });
83
+ return res;
84
+ }
85
+ };
86
+ exports.D2CController = D2CController;
87
+ __decorate([
88
+ (0, common_1.Post)('convert'),
89
+ __param(0, (0, common_1.Body)()),
90
+ __param(1, (0, common_1.Headers)('X-Figma-Token')),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [ConvertDto, String]),
93
+ __metadata("design:returntype", Promise)
94
+ ], D2CController.prototype, "convert", null);
95
+ __decorate([
96
+ (0, common_1.Get)('download'),
97
+ __param(0, (0, common_1.Query)('fileKey')),
98
+ __param(1, (0, common_1.Query)('nodeId')),
99
+ __param(2, (0, common_1.Headers)('X-Figma-Token')),
100
+ __metadata("design:type", Function),
101
+ __metadata("design:paramtypes", [String, String, String]),
102
+ __metadata("design:returntype", Promise)
103
+ ], D2CController.prototype, "download", null);
104
+ exports.D2CController = D2CController = __decorate([
105
+ (0, common_1.Controller)('d2c'),
106
+ __metadata("design:paramtypes", [d2c_service_1.D2CService])
107
+ ], D2CController);
108
+ //# sourceMappingURL=d2c.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d2c.controller.js","sourceRoot":"","sources":["../../../src/modules/d2c/d2c.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4E;AAC5E,+CAA0C;AAC1C,uCAAwB;AACxB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAElC,MAAM,UAAU;CAOf;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGjD,AAAN,KAAK,CAAC,OAAO,CAAS,UAAsB,EAA4B,UAAkB;QACxF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;QAC3D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAClE,OAAO;YACP,MAAM;YACN,KAAK;YACL,UAAU;YACV,IAAI;YACJ,MAAM;SACP,CAAC,CAAA;QAGF,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACpC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;QAClC,OAAO;YACL,IAAI,EAAE,CAAC;YACP,IAAI,EAAE;gBACJ,IAAI;gBACJ,QAAQ;gBACR,SAAS;aACV;SACF,CAAA;IACH,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAmB,OAAe,EAAmB,MAAc,EAA4B,UAAkB;QAC7H,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAI3E,OAAO,GAAG,CAAA;IACZ,CAAC;CACF,CAAA;AArCY,sCAAa;AAIlB;IADL,IAAA,aAAI,EAAC,SAAS,CAAC;IACD,WAAA,IAAA,aAAI,GAAE,CAAA;IAA0B,WAAA,IAAA,gBAAO,EAAC,eAAe,CAAC,CAAA;;qCAArC,UAAU;;4CAuB3C;AAGK;IADL,IAAA,YAAG,EAAC,UAAU,CAAC;IACA,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;IAAmB,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IAAkB,WAAA,IAAA,gBAAO,EAAC,eAAe,CAAC,CAAA;;;;6CAM3G;wBApCU,aAAa;IADzB,IAAA,mBAAU,EAAC,KAAK,CAAC;qCAEyB,wBAAU;GADxC,aAAa,CAqCzB"}
@@ -0,0 +1,2 @@
1
+ export declare class D2CModule {
2
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.D2CModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const d2c_service_1 = require("./d2c.service");
12
+ const d2c_controller_1 = require("./d2c.controller");
13
+ const axios_1 = require("@nestjs/axios");
14
+ const figma_1 = require("../../utils/figma");
15
+ let D2CModule = class D2CModule {
16
+ };
17
+ exports.D2CModule = D2CModule;
18
+ exports.D2CModule = D2CModule = __decorate([
19
+ (0, common_1.Global)(),
20
+ (0, common_1.Module)({
21
+ imports: [axios_1.HttpModule],
22
+ providers: [d2c_service_1.D2CService, figma_1.FigmaService],
23
+ exports: [d2c_service_1.D2CService],
24
+ controllers: [d2c_controller_1.D2CController],
25
+ })
26
+ ], D2CModule);
27
+ //# sourceMappingURL=d2c.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d2c.module.js","sourceRoot":"","sources":["../../../src/modules/d2c/d2c.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA+C;AAC/C,+CAA2C;AAC3C,qDAAiD;AACjD,yCAA2C;AAC3C,6CAAiD;AAQ1C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAPrB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,kBAAU,CAAC;QACrB,SAAS,EAAE,CAAC,wBAAU,EAAE,oBAAY,CAAC;QACrC,OAAO,EAAE,CAAC,wBAAU,CAAC;QACrB,WAAW,EAAE,CAAC,8BAAa,CAAC;KAC7B,CAAC;GACW,SAAS,CAAG"}
@@ -0,0 +1,12 @@
1
+ import { ConvertParams, ConvertResult } from '../../utils/d2c-convert';
2
+ import { FigmaService } from '../../utils/figma';
3
+ export declare class D2CService {
4
+ private readonly figmaService;
5
+ constructor(figmaService: FigmaService);
6
+ convert(params: ConvertParams): Promise<ConvertResult>;
7
+ download({ fileKey, nodeId, figmaToken }: {
8
+ fileKey: string;
9
+ nodeId: string;
10
+ figmaToken: string;
11
+ }): Promise<any>;
12
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.D2CService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const d2c_convert_1 = require("../../utils/d2c-convert");
15
+ const figma_1 = require("../../utils/figma");
16
+ const flatted = require('flatted');
17
+ let D2CService = class D2CService {
18
+ constructor(figmaService) {
19
+ this.figmaService = figmaService;
20
+ }
21
+ async convert(params) {
22
+ return await (0, d2c_convert_1.convertD2C)(params);
23
+ }
24
+ async download({ fileKey, nodeId, figmaToken }) {
25
+ const image = await this.figmaService.getImage(fileKey, nodeId, figmaToken, {
26
+ ids: nodeId,
27
+ format: 'png',
28
+ scale: 2,
29
+ use_absolute_bounds: true,
30
+ });
31
+ console.log('get service ,image', image);
32
+ return image.images[nodeId];
33
+ }
34
+ };
35
+ exports.D2CService = D2CService;
36
+ exports.D2CService = D2CService = __decorate([
37
+ (0, common_1.Injectable)(),
38
+ __metadata("design:paramtypes", [figma_1.FigmaService])
39
+ ], D2CService);
40
+ //# sourceMappingURL=d2c.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d2c.service.js","sourceRoot":"","sources":["../../../src/modules/d2c/d2c.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,yDAAkF;AAClF,6CAAgD;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAG3B,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAC3D,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,OAAO,MAAM,IAAA,wBAAU,EAAC,MAAM,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAA2D;QACrG,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE;YAC1E,GAAG,EAAE,MAAM;YACX,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,CAAC;YACR,mBAAmB,EAAE,IAAI;SAE1B,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;QACxC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;CACF,CAAA;AAjBY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAEgC,oBAAY;GAD5C,UAAU,CAiBtB"}