deepline 0.1.155 → 0.1.157
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/bundling-sources/apps/play-runner-workers/src/entry.ts +146 -14
- package/dist/bundling-sources/apps/play-runner-workers/src/runtime/map-chunk-plan.ts +53 -1
- package/dist/bundling-sources/sdk/src/play.ts +4 -2
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +8 -4
- package/dist/bundling-sources/shared_libs/play-runtime/execution-plan.ts +159 -42
- package/dist/bundling-sources/shared_libs/play-runtime/map-chunk-limits.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +0 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +19 -3
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +464 -226
- package/dist/cli/index.js +76 -29
- package/dist/cli/index.mjs +100 -49
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plays/bundle-play-file.mjs +318 -181
- package/package.json +3 -1
|
@@ -19,7 +19,9 @@ import {
|
|
|
19
19
|
resolve
|
|
20
20
|
} from "path";
|
|
21
21
|
import { builtinModules } from "module";
|
|
22
|
-
import {
|
|
22
|
+
import { Parser } from "acorn";
|
|
23
|
+
import { tsPlugin } from "acorn-typescript";
|
|
24
|
+
import { build, transformSync } from "esbuild";
|
|
23
25
|
|
|
24
26
|
// ../shared_libs/play-runtime/backend.ts
|
|
25
27
|
var PLAY_RUNTIME_BACKENDS = {
|
|
@@ -364,24 +366,6 @@ function findSourceImportReferences(sourceCode) {
|
|
|
364
366
|
(left, right) => left.line === right.line ? left.column - right.column : left.line - right.line
|
|
365
367
|
);
|
|
366
368
|
}
|
|
367
|
-
function unquoteStringLiteral(literal) {
|
|
368
|
-
const trimmed = literal.trim();
|
|
369
|
-
const quote = trimmed[0];
|
|
370
|
-
if (quote !== '"' && quote !== "'" && quote !== "`" || trimmed[trimmed.length - 1] !== quote) {
|
|
371
|
-
return null;
|
|
372
|
-
}
|
|
373
|
-
if (quote === "`") {
|
|
374
|
-
const value = trimmed.slice(1, -1);
|
|
375
|
-
return value.includes("${") ? null : value;
|
|
376
|
-
}
|
|
377
|
-
try {
|
|
378
|
-
return JSON.parse(
|
|
379
|
-
quote === '"' ? trimmed : `"${trimmed.slice(1, -1).replace(/"/g, '\\"')}"`
|
|
380
|
-
);
|
|
381
|
-
} catch {
|
|
382
|
-
return trimmed.slice(1, -1);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
369
|
function findMatchingBrace(source, openIndex) {
|
|
386
370
|
const structuralSource = maskSourceForStructure(source);
|
|
387
371
|
let depth = 0;
|
|
@@ -395,198 +379,351 @@ function findMatchingBrace(source, openIndex) {
|
|
|
395
379
|
}
|
|
396
380
|
return -1;
|
|
397
381
|
}
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
let depth = 0;
|
|
401
|
-
for (let index = openIndex; index < structuralSource.length; index += 1) {
|
|
402
|
-
const char = structuralSource[index];
|
|
403
|
-
if (char === "(") depth += 1;
|
|
404
|
-
if (char === ")") {
|
|
405
|
-
depth -= 1;
|
|
406
|
-
if (depth === 0) return index;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
return -1;
|
|
382
|
+
function extractDefinedPlayName(sourceCode) {
|
|
383
|
+
return extractDefinedPlayMetadata(sourceCode, null)?.name ?? null;
|
|
410
384
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
385
|
+
function extractDefinedPlayNameForExport(sourceCode, exportName) {
|
|
386
|
+
return extractDefinedPlayMetadata(sourceCode, exportName)?.name ?? null;
|
|
387
|
+
}
|
|
388
|
+
function extractDefinedPlayDescription(sourceCode) {
|
|
389
|
+
return extractDefinedPlayMetadata(sourceCode, null)?.description ?? null;
|
|
390
|
+
}
|
|
391
|
+
function extractDefinedPlayDescriptionForExport(sourceCode, exportName) {
|
|
392
|
+
return extractDefinedPlayMetadata(sourceCode, exportName)?.description ?? null;
|
|
393
|
+
}
|
|
394
|
+
var TypeScriptParser = Parser.extend(
|
|
395
|
+
tsPlugin({
|
|
396
|
+
allowSatisfies: true,
|
|
397
|
+
jsx: {
|
|
398
|
+
allowNamespaces: true,
|
|
399
|
+
allowNamespacedObjects: true
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
function parsePlaySourceAst(sourceCode) {
|
|
404
|
+
try {
|
|
405
|
+
return TypeScriptParser.parse(sourceCode, {
|
|
406
|
+
ecmaVersion: "latest",
|
|
407
|
+
sourceType: "module",
|
|
408
|
+
allowHashBang: true
|
|
409
|
+
});
|
|
410
|
+
} catch {
|
|
411
|
+
try {
|
|
412
|
+
const transformed = transformSync(sourceCode, {
|
|
413
|
+
loader: "ts",
|
|
414
|
+
format: "esm",
|
|
415
|
+
target: "esnext",
|
|
416
|
+
legalComments: "none",
|
|
417
|
+
sourcemap: false
|
|
418
|
+
}).code;
|
|
419
|
+
return Parser.parse(transformed, {
|
|
420
|
+
ecmaVersion: "latest",
|
|
421
|
+
sourceType: "module",
|
|
422
|
+
allowHashBang: true
|
|
423
|
+
});
|
|
424
|
+
} catch {
|
|
425
|
+
return null;
|
|
429
426
|
}
|
|
430
427
|
}
|
|
431
|
-
const finalArg = source.slice(start).trim();
|
|
432
|
-
if (finalArg) args.push(finalArg);
|
|
433
|
-
return args;
|
|
434
428
|
}
|
|
435
|
-
function
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
429
|
+
function getIdentifierName(node) {
|
|
430
|
+
return isAstNode(node) && node.type === "Identifier" ? typeof node.name === "string" ? node.name : null : null;
|
|
431
|
+
}
|
|
432
|
+
function isAstNode(value) {
|
|
433
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
434
|
+
}
|
|
435
|
+
function astArray(value) {
|
|
436
|
+
return Array.isArray(value) ? value.filter(isAstNode) : [];
|
|
437
|
+
}
|
|
438
|
+
function memberExpressionPath(node) {
|
|
439
|
+
const expression = unwrapStaticExpression(node);
|
|
440
|
+
if (!expression) return null;
|
|
441
|
+
if (expression.type === "Identifier" && typeof expression.name === "string") {
|
|
442
|
+
return [expression.name];
|
|
443
|
+
}
|
|
444
|
+
if (expression.type !== "MemberExpression") return null;
|
|
445
|
+
const objectPath = memberExpressionPath(
|
|
446
|
+
isAstNode(expression.object) ? expression.object : null
|
|
447
|
+
);
|
|
448
|
+
if (!objectPath) return null;
|
|
449
|
+
const property = isAstNode(expression.property) ? expression.property : null;
|
|
450
|
+
if (!property) return null;
|
|
451
|
+
if (!expression.computed && property.type === "Identifier") {
|
|
452
|
+
return typeof property.name === "string" ? [...objectPath, property.name] : null;
|
|
453
|
+
}
|
|
454
|
+
if (expression.computed && property.type === "Literal") {
|
|
455
|
+
return typeof property.value === "string" ? [...objectPath, property.value] : null;
|
|
445
456
|
}
|
|
446
457
|
return null;
|
|
447
458
|
}
|
|
448
|
-
function
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
459
|
+
function commonJsExportName(left) {
|
|
460
|
+
const path = memberExpressionPath(left);
|
|
461
|
+
if (!path) return null;
|
|
462
|
+
if (path.length === 2 && path[0] === "module" && path[1] === "exports") {
|
|
463
|
+
return "default";
|
|
464
|
+
}
|
|
465
|
+
if (path.length === 3 && path[0] === "module" && path[1] === "exports") {
|
|
466
|
+
return path[2] || null;
|
|
467
|
+
}
|
|
468
|
+
if (path.length === 2 && path[0] === "exports") {
|
|
469
|
+
return path[1] || null;
|
|
452
470
|
}
|
|
453
471
|
return null;
|
|
454
472
|
}
|
|
455
|
-
function
|
|
456
|
-
return
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
473
|
+
function isDefinePlayCallExpression(node) {
|
|
474
|
+
if (!node || node.type !== "CallExpression") return false;
|
|
475
|
+
const callee = isAstNode(node.callee) ? node.callee : null;
|
|
476
|
+
if (!callee) return false;
|
|
477
|
+
if (callee.type === "Identifier") {
|
|
478
|
+
return callee.name === "definePlay" || callee.name === "defineWorkflow";
|
|
479
|
+
}
|
|
480
|
+
if (callee.type === "MemberExpression" && isAstNode(callee.property)) {
|
|
481
|
+
const property = callee.property;
|
|
482
|
+
return !callee.computed && property.type === "Identifier" && (property.name === "definePlay" || property.name === "defineWorkflow");
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
function canResolveDeclarationInitializer(declarationKind, initializer) {
|
|
487
|
+
return declarationKind === "const" || isDefinePlayCallExpression(initializer);
|
|
488
|
+
}
|
|
489
|
+
function buildPlayMetadataContext(ast) {
|
|
490
|
+
const declarations = /* @__PURE__ */ new Map();
|
|
491
|
+
const namedExports = /* @__PURE__ */ new Map();
|
|
492
|
+
const commonJsExports = /* @__PURE__ */ new Map();
|
|
493
|
+
let defaultExport = null;
|
|
494
|
+
for (const statement of astArray(ast.body)) {
|
|
495
|
+
if (statement.type === "VariableDeclaration") {
|
|
496
|
+
for (const declaration of astArray(statement.declarations)) {
|
|
497
|
+
const name = getIdentifierName(declaration.id);
|
|
498
|
+
if (!name) continue;
|
|
499
|
+
const initializer = isAstNode(declaration.init) ? declaration.init : null;
|
|
500
|
+
declarations.set(
|
|
501
|
+
name,
|
|
502
|
+
canResolveDeclarationInitializer(statement.kind, initializer) ? initializer : null
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (statement.type === "ExportDefaultDeclaration") {
|
|
508
|
+
defaultExport = isAstNode(statement.declaration) ? statement.declaration : null;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (statement.type === "TSExportAssignment") {
|
|
512
|
+
defaultExport = isAstNode(statement.expression) ? statement.expression : null;
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
if (statement.type === "ExportNamedDeclaration") {
|
|
516
|
+
if (isAstNode(statement.declaration) && statement.declaration.type === "VariableDeclaration") {
|
|
517
|
+
for (const declaration of astArray(statement.declaration.declarations)) {
|
|
518
|
+
const name = getIdentifierName(declaration.id);
|
|
519
|
+
if (!name) continue;
|
|
520
|
+
const initializer = isAstNode(declaration.init) ? declaration.init : null;
|
|
521
|
+
declarations.set(
|
|
522
|
+
name,
|
|
523
|
+
canResolveDeclarationInitializer(
|
|
524
|
+
statement.declaration.kind,
|
|
525
|
+
initializer
|
|
526
|
+
) ? initializer : null
|
|
527
|
+
);
|
|
528
|
+
namedExports.set(name, name);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
for (const specifier of astArray(statement.specifiers)) {
|
|
532
|
+
const localName = getIdentifierName(specifier.local);
|
|
533
|
+
const exportedName = getIdentifierName(specifier.exported) ?? (isAstNode(specifier.exported) && specifier.exported.type === "Literal" && typeof specifier.exported.value === "string" ? specifier.exported.value : null);
|
|
534
|
+
if (localName && exportedName) {
|
|
535
|
+
namedExports.set(exportedName, localName);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (statement.type === "ExpressionStatement" && isAstNode(statement.expression) && statement.expression.type === "AssignmentExpression") {
|
|
540
|
+
const exportName = commonJsExportName(
|
|
541
|
+
isAstNode(statement.expression.left) ? statement.expression.left : null
|
|
542
|
+
);
|
|
543
|
+
if (exportName && isAstNode(statement.expression.right)) {
|
|
544
|
+
commonJsExports.set(exportName, statement.expression.right);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return { declarations, namedExports, commonJsExports, defaultExport };
|
|
549
|
+
}
|
|
550
|
+
function unwrapStaticExpression(node) {
|
|
551
|
+
let current = node ?? null;
|
|
552
|
+
while (current && (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression")) {
|
|
553
|
+
current = isAstNode(current.expression) ? current.expression : null;
|
|
554
|
+
}
|
|
555
|
+
return current;
|
|
556
|
+
}
|
|
557
|
+
function staticStringFromExpression(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
558
|
+
const expression = unwrapStaticExpression(node);
|
|
559
|
+
if (!expression) return null;
|
|
560
|
+
if (expression.type === "Literal") {
|
|
561
|
+
const value = expression.value;
|
|
562
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
563
|
+
}
|
|
564
|
+
if (expression.type === "TemplateLiteral" && astArray(expression.expressions).length === 0) {
|
|
565
|
+
const firstQuasi = astArray(expression.quasis)[0];
|
|
566
|
+
const cooked = firstQuasi && typeof firstQuasi.value === "object" ? firstQuasi.value.cooked : null;
|
|
567
|
+
return typeof cooked === "string" && cooked.trim() ? cooked.trim() : null;
|
|
568
|
+
}
|
|
569
|
+
const identifier = getIdentifierName(expression);
|
|
570
|
+
if (!identifier || seen.has(identifier)) return null;
|
|
571
|
+
seen.add(identifier);
|
|
572
|
+
return staticStringFromExpression(
|
|
573
|
+
context.declarations.get(identifier),
|
|
574
|
+
context,
|
|
575
|
+
seen
|
|
460
576
|
);
|
|
461
577
|
}
|
|
462
|
-
function
|
|
463
|
-
return
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
578
|
+
function propertyNameFromKey(property) {
|
|
579
|
+
if (property.computed) return null;
|
|
580
|
+
const key = isAstNode(property.key) ? property.key : null;
|
|
581
|
+
if (!key) return null;
|
|
582
|
+
if (key.type === "Identifier" && typeof key.name === "string") {
|
|
583
|
+
return key.name;
|
|
584
|
+
}
|
|
585
|
+
if (key.type === "Literal" && typeof key.value === "string") {
|
|
586
|
+
return key.value;
|
|
587
|
+
}
|
|
588
|
+
return null;
|
|
468
589
|
}
|
|
469
|
-
function
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
590
|
+
function objectExpressionFromNode(node, context, seen = /* @__PURE__ */ new Set()) {
|
|
591
|
+
const expression = unwrapStaticExpression(node);
|
|
592
|
+
if (!expression) return null;
|
|
593
|
+
if (expression.type === "ObjectExpression") return expression;
|
|
594
|
+
const identifier = getIdentifierName(expression);
|
|
595
|
+
if (!identifier || seen.has(identifier)) return null;
|
|
596
|
+
seen.add(identifier);
|
|
597
|
+
return objectExpressionFromNode(
|
|
598
|
+
context.declarations.get(identifier),
|
|
599
|
+
context,
|
|
600
|
+
seen
|
|
474
601
|
);
|
|
475
602
|
}
|
|
476
|
-
function
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
603
|
+
function stringPropertyFromObjectExpression(node, propertyName, context, seenObjects = /* @__PURE__ */ new Set()) {
|
|
604
|
+
const object = objectExpressionFromNode(node, context);
|
|
605
|
+
if (!object || seenObjects.has(object)) return null;
|
|
606
|
+
seenObjects.add(object);
|
|
607
|
+
let value = null;
|
|
608
|
+
for (const property of astArray(object.properties)) {
|
|
609
|
+
if (property.type === "SpreadElement") {
|
|
610
|
+
const spreadValue = stringPropertyFromObjectExpression(
|
|
611
|
+
isAstNode(property.argument) ? property.argument : null,
|
|
612
|
+
propertyName,
|
|
613
|
+
context,
|
|
614
|
+
seenObjects
|
|
615
|
+
);
|
|
616
|
+
if (spreadValue) value = spreadValue;
|
|
480
617
|
continue;
|
|
481
618
|
}
|
|
482
|
-
|
|
483
|
-
if (
|
|
619
|
+
if (property.type !== "Property") continue;
|
|
620
|
+
if (propertyNameFromKey(property) !== propertyName) continue;
|
|
621
|
+
const propertyValue = property.shorthand ? property.key : property.value;
|
|
622
|
+
value = staticStringFromExpression(
|
|
623
|
+
isAstNode(propertyValue) ? propertyValue : null,
|
|
624
|
+
context
|
|
625
|
+
);
|
|
484
626
|
}
|
|
485
|
-
return
|
|
627
|
+
return value;
|
|
486
628
|
}
|
|
487
|
-
function
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
calls.push({
|
|
497
|
-
arguments: splitTopLevelArguments(
|
|
498
|
-
sourceCode.slice(openParen + 1, closeParen)
|
|
499
|
-
),
|
|
500
|
-
exportName: exportNameForDefinePlayCall(sourceCode, callStart)
|
|
501
|
-
});
|
|
629
|
+
function isDefinePlayCallee(node) {
|
|
630
|
+
const callee = unwrapStaticExpression(node);
|
|
631
|
+
if (!callee) return false;
|
|
632
|
+
if (callee.type === "Identifier" && (callee.name === "definePlay" || callee.name === "defineWorkflow")) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
if (callee.type === "MemberExpression" && isAstNode(callee.property)) {
|
|
636
|
+
const property = callee.property;
|
|
637
|
+
return !callee.computed && property.type === "Identifier" && (property.name === "definePlay" || property.name === "defineWorkflow");
|
|
502
638
|
}
|
|
503
|
-
return
|
|
639
|
+
return false;
|
|
504
640
|
}
|
|
505
|
-
function
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const afterIdentifier = match.index + match[0].length;
|
|
510
|
-
const nextNonSpace = source.slice(afterIdentifier).match(/\S/)?.[0] ?? "";
|
|
511
|
-
if (nextNonSpace !== "(") return match[1] ?? null;
|
|
641
|
+
function playMetadataFromDefinePlayCall(node, context) {
|
|
642
|
+
const expression = unwrapStaticExpression(node);
|
|
643
|
+
if (!expression || expression.type !== "CallExpression" || !isDefinePlayCallee(isAstNode(expression.callee) ? expression.callee : null)) {
|
|
644
|
+
return null;
|
|
512
645
|
}
|
|
513
|
-
|
|
646
|
+
const args = astArray(expression.arguments);
|
|
647
|
+
const firstArg = args[0] ?? null;
|
|
648
|
+
const objectName = stringPropertyFromObjectExpression(firstArg, "id", context);
|
|
649
|
+
const name = objectName ?? staticStringFromExpression(firstArg, context);
|
|
650
|
+
let description = stringPropertyFromObjectExpression(firstArg, "description", context) ?? null;
|
|
651
|
+
for (let index = args.length - 1; !description && index >= 2; index -= 1) {
|
|
652
|
+
description = stringPropertyFromObjectExpression(
|
|
653
|
+
args[index],
|
|
654
|
+
"description",
|
|
655
|
+
context
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
if (!name && !description) return null;
|
|
659
|
+
return { name, description };
|
|
514
660
|
}
|
|
515
|
-
function
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
661
|
+
function resolveExportExpression(exportName, context) {
|
|
662
|
+
if (exportName === "default") {
|
|
663
|
+
const commonJsDefault = context.commonJsExports.get("default");
|
|
664
|
+
if (commonJsDefault) {
|
|
665
|
+
const commonJsDefaultIdentifier = getIdentifierName(
|
|
666
|
+
unwrapStaticExpression(commonJsDefault)
|
|
667
|
+
);
|
|
668
|
+
return commonJsDefaultIdentifier ? context.declarations.get(commonJsDefaultIdentifier) ?? commonJsDefault : commonJsDefault;
|
|
669
|
+
}
|
|
670
|
+
const defaultExpression = unwrapStaticExpression(context.defaultExport);
|
|
671
|
+
const defaultIdentifier = getIdentifierName(defaultExpression);
|
|
672
|
+
if (!defaultIdentifier) {
|
|
673
|
+
const defaultExportName = context.namedExports.get("default");
|
|
674
|
+
return defaultExportName ? context.declarations.get(defaultExportName) ?? null : defaultExpression;
|
|
675
|
+
}
|
|
676
|
+
return defaultIdentifier ? context.declarations.get(defaultIdentifier) ?? context.defaultExport : context.defaultExport;
|
|
677
|
+
}
|
|
678
|
+
if (exportName) {
|
|
679
|
+
const commonJsExport = context.commonJsExports.get(exportName);
|
|
680
|
+
if (commonJsExport) {
|
|
681
|
+
const commonJsExportIdentifier = getIdentifierName(
|
|
682
|
+
unwrapStaticExpression(commonJsExport)
|
|
683
|
+
);
|
|
684
|
+
return commonJsExportIdentifier ? context.declarations.get(commonJsExportIdentifier) ?? commonJsExport : commonJsExport;
|
|
685
|
+
}
|
|
686
|
+
const localName = context.namedExports.get(exportName) ?? exportName;
|
|
687
|
+
return context.declarations.get(localName) ?? null;
|
|
523
688
|
}
|
|
524
689
|
return null;
|
|
525
690
|
}
|
|
526
|
-
function
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
691
|
+
function extractDefinedPlayMetadata(sourceCode, exportName) {
|
|
692
|
+
const ast = parsePlaySourceAst(sourceCode);
|
|
693
|
+
if (!ast) return null;
|
|
694
|
+
const context = buildPlayMetadataContext(ast);
|
|
695
|
+
const exportedExpression = resolveExportExpression(exportName, context);
|
|
696
|
+
const exportedMetadata = playMetadataFromDefinePlayCall(
|
|
697
|
+
exportedExpression,
|
|
698
|
+
context
|
|
530
699
|
);
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
700
|
+
if (exportedMetadata) return exportedMetadata;
|
|
701
|
+
if (exportName) return null;
|
|
702
|
+
if (context.defaultExport) {
|
|
703
|
+
const directDefaultMetadata = playMetadataFromDefinePlayCall(
|
|
704
|
+
context.defaultExport,
|
|
705
|
+
context
|
|
536
706
|
);
|
|
537
|
-
if (
|
|
707
|
+
if (directDefaultMetadata) return directDefaultMetadata;
|
|
708
|
+
const defaultIdentifier = getIdentifierName(context.defaultExport);
|
|
709
|
+
if (defaultIdentifier) {
|
|
710
|
+
const defaultMetadata = playMetadataFromDefinePlayCall(
|
|
711
|
+
context.declarations.get(defaultIdentifier),
|
|
712
|
+
context
|
|
713
|
+
);
|
|
714
|
+
if (defaultMetadata) return defaultMetadata;
|
|
715
|
+
}
|
|
538
716
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
return extractStringProperty(objectSource, "description");
|
|
547
|
-
}
|
|
548
|
-
function objectLiteralBodyFromArgument(sourceCode, arg) {
|
|
549
|
-
const trimmed = arg.trim();
|
|
550
|
-
if (trimmed.startsWith("{")) {
|
|
551
|
-
const closeBrace = findMatchingBrace(trimmed, 0);
|
|
552
|
-
return closeBrace >= 0 ? trimmed.slice(1, closeBrace) : trimmed.slice(1);
|
|
553
|
-
}
|
|
554
|
-
if (!/^[A-Za-z_$][\w$]*$/.test(trimmed)) return null;
|
|
555
|
-
return findTopLevelObjectLiteralBody(sourceCode, trimmed);
|
|
556
|
-
}
|
|
557
|
-
function escapeRegExp(value) {
|
|
558
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
559
|
-
}
|
|
560
|
-
function findTopLevelObjectLiteralBody(sourceCode, identifier) {
|
|
561
|
-
const source = maskSourceForStructure(sourceCode);
|
|
562
|
-
const pattern = new RegExp(
|
|
563
|
-
`(?:^|[;\\n])\\s*(?:export\\s+)?(?:const|let|var)\\s+${escapeRegExp(
|
|
564
|
-
identifier
|
|
565
|
-
)}(?:\\s*:[^=;]+)?\\s*=\\s*{`,
|
|
566
|
-
"g"
|
|
567
|
-
);
|
|
568
|
-
for (const match of source.matchAll(pattern)) {
|
|
569
|
-
const openBrace = source.indexOf("{", match.index);
|
|
570
|
-
if (openBrace < 0) continue;
|
|
571
|
-
const closeBrace = findMatchingBrace(sourceCode, openBrace);
|
|
572
|
-
if (closeBrace < 0) continue;
|
|
573
|
-
return sourceCode.slice(openBrace + 1, closeBrace);
|
|
717
|
+
for (const expression of context.declarations.values()) {
|
|
718
|
+
const metadata = playMetadataFromDefinePlayCall(expression, context);
|
|
719
|
+
if (metadata) return metadata;
|
|
720
|
+
}
|
|
721
|
+
for (const expression of context.commonJsExports.values()) {
|
|
722
|
+
const metadata = playMetadataFromDefinePlayCall(expression, context);
|
|
723
|
+
if (metadata) return metadata;
|
|
574
724
|
}
|
|
575
725
|
return null;
|
|
576
726
|
}
|
|
577
|
-
function exportNameForDefinePlayCall(sourceCode, callStart) {
|
|
578
|
-
const source = maskSourceForStructure(sourceCode);
|
|
579
|
-
const structuralPrefix = source.slice(Math.max(0, callStart - 500), callStart).trimEnd();
|
|
580
|
-
if (/\bexport\s+default\s*$/.test(structuralPrefix)) return "default";
|
|
581
|
-
const variableMatch = structuralPrefix.match(
|
|
582
|
-
/\bexport\s+(?:declare\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)(?:\s*:[^=;]+)?\s*=\s*$/
|
|
583
|
-
);
|
|
584
|
-
if (variableMatch?.[1]) return variableMatch[1];
|
|
585
|
-
const localVariableMatch = structuralPrefix.match(
|
|
586
|
-
/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)(?:\s*:[^=;]+)?\s*=\s*$/
|
|
587
|
-
);
|
|
588
|
-
return localVariableMatch?.[1] ?? null;
|
|
589
|
-
}
|
|
590
727
|
function canonicalizeRootPlayNameForWorkersRuntimeHash(sourceCode) {
|
|
591
728
|
const source = stripCommentsToSpaces(sourceCode);
|
|
592
729
|
const callPattern = /(?:\b[A-Za-z_$][\w$]*\s*\.\s*)?\b(?:definePlay|defineWorkflow)\s*\(/g;
|
|
@@ -1682,7 +1819,7 @@ function stripCommentsToSpaces2(source) {
|
|
|
1682
1819
|
(match, prefix) => prefix + " ".repeat(Math.max(0, match.length - prefix.length))
|
|
1683
1820
|
);
|
|
1684
1821
|
}
|
|
1685
|
-
function
|
|
1822
|
+
function unquoteStringLiteral(literal) {
|
|
1686
1823
|
const trimmed = literal.trim();
|
|
1687
1824
|
const quote = trimmed[0];
|
|
1688
1825
|
if (quote !== '"' && quote !== "'" || trimmed[trimmed.length - 1] !== quote) {
|
|
@@ -1742,7 +1879,7 @@ function isRuntimeInputExpression(expression) {
|
|
|
1742
1879
|
function resolveStringExpression(expression, constants) {
|
|
1743
1880
|
const value = stripOuterParens(expression);
|
|
1744
1881
|
if (/^(['"])(?:\\.|(?!\1)[\s\S])*\1$/.test(value)) {
|
|
1745
|
-
return
|
|
1882
|
+
return unquoteStringLiteral(value);
|
|
1746
1883
|
}
|
|
1747
1884
|
if (/^`(?:\\.|[^`$]|\$(?!\{))*`$/.test(value)) {
|
|
1748
1885
|
return value.slice(1, -1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepline",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.157",
|
|
4
4
|
"description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"prepublishOnly": "bun ../scripts/sync-sdk-package-version.ts && tsup"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
+
"acorn": "^8.17.0",
|
|
50
|
+
"acorn-typescript": "^1.4.13",
|
|
49
51
|
"commander": "^14.0.3",
|
|
50
52
|
"csv-parse": "^5.6.0",
|
|
51
53
|
"csv-stringify": "^6.5.0",
|