@inlang/sdk 2.1.3 → 2.2.1

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 (155) hide show
  1. package/dist/database/initDb.js +1 -4
  2. package/dist/database/initDb.js.map +1 -1
  3. package/dist/database/initDbAndSchema.test.js +1 -4
  4. package/dist/database/initDbAndSchema.test.js.map +1 -1
  5. package/dist/database/jsonbPlugin.js +1 -4
  6. package/dist/database/jsonbPlugin.js.map +1 -1
  7. package/dist/database/jsonbPlugin.test.js +1 -4
  8. package/dist/database/jsonbPlugin.test.js.map +1 -1
  9. package/dist/database/schema.js +1 -4
  10. package/dist/database/schema.js.map +1 -1
  11. package/dist/helper.js +1 -4
  12. package/dist/helper.js.map +1 -1
  13. package/dist/human-id/human-id.js +1 -4
  14. package/dist/human-id/human-id.js.map +1 -1
  15. package/dist/human-id/words.js +1 -4
  16. package/dist/human-id/words.js.map +1 -1
  17. package/dist/human-id/words.test.js +1 -4
  18. package/dist/human-id/words.test.js.map +1 -1
  19. package/dist/import-export/exportFiles.js +1 -4
  20. package/dist/import-export/exportFiles.js.map +1 -1
  21. package/dist/import-export/importFiles.js +1 -4
  22. package/dist/import-export/importFiles.js.map +1 -1
  23. package/dist/import-export/importFiles.test.js +1 -4
  24. package/dist/import-export/importFiles.test.js.map +1 -1
  25. package/dist/import-export/roundtrip.test.js +1 -4
  26. package/dist/import-export/roundtrip.test.js.map +1 -1
  27. package/dist/import-export/upsertBundleNestedMatchByProperties.js +1 -4
  28. package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -1
  29. package/dist/index.js +1 -4
  30. package/dist/index.js.map +1 -1
  31. package/dist/json-schema/old-v1-message/fromMessageV1.js +1 -4
  32. package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -1
  33. package/dist/json-schema/old-v1-message/fromMessageV1.test.js +1 -4
  34. package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -1
  35. package/dist/json-schema/old-v1-message/schemaV1.js +1 -4
  36. package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -1
  37. package/dist/json-schema/old-v1-message/toMessageV1.js +1 -4
  38. package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -1
  39. package/dist/json-schema/old-v1-message/toMessageV1.test.js +1 -4
  40. package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -1
  41. package/dist/json-schema/pattern.js +1 -4
  42. package/dist/json-schema/pattern.js.map +1 -1
  43. package/dist/json-schema/settings.js +1 -4
  44. package/dist/json-schema/settings.js.map +1 -1
  45. package/dist/json-schema/settings.test-d.js +1 -4
  46. package/dist/json-schema/settings.test-d.js.map +1 -1
  47. package/dist/json-schema/settings.test.js +1 -4
  48. package/dist/json-schema/settings.test.js.map +1 -1
  49. package/dist/lix/index.js +1 -4
  50. package/dist/lix/index.js.map +1 -1
  51. package/dist/lix-plugin/applyChanges.js +1 -4
  52. package/dist/lix-plugin/applyChanges.js.map +1 -1
  53. package/dist/lix-plugin/applyChanges.test.js +1 -4
  54. package/dist/lix-plugin/applyChanges.test.js.map +1 -1
  55. package/dist/lix-plugin/detectConflicts.js +1 -4
  56. package/dist/lix-plugin/detectConflicts.js.map +1 -1
  57. package/dist/lix-plugin/detectConflicts.test.js +1 -4
  58. package/dist/lix-plugin/detectConflicts.test.js.map +1 -1
  59. package/dist/lix-plugin/inlangLixPluginV1.js +1 -4
  60. package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -1
  61. package/dist/lix-plugin/inlangLixPluginV1.test.js +1 -4
  62. package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -1
  63. package/dist/lix-plugin/merge.test.js +1 -4
  64. package/dist/lix-plugin/merge.test.js.map +1 -1
  65. package/dist/lix-plugin/resolveConflictBySelecting.test.js +1 -4
  66. package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -1
  67. package/dist/migrations/v2/createMessageV1.js +1 -4
  68. package/dist/migrations/v2/createMessageV1.js.map +1 -1
  69. package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +1 -4
  70. package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -1
  71. package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +1 -4
  72. package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -1
  73. package/dist/plugin/cache.js +1 -4
  74. package/dist/plugin/cache.js.map +1 -1
  75. package/dist/plugin/cache.test.js +1 -4
  76. package/dist/plugin/cache.test.js.map +1 -1
  77. package/dist/plugin/errors.js +1 -4
  78. package/dist/plugin/errors.js.map +1 -1
  79. package/dist/plugin/importPlugins.d.ts.map +1 -1
  80. package/dist/plugin/importPlugins.js +11 -7
  81. package/dist/plugin/importPlugins.js.map +1 -1
  82. package/dist/plugin/importPlugins.test.js +1 -4
  83. package/dist/plugin/importPlugins.test.js.map +1 -1
  84. package/dist/plugin/meta/ideExtension.js +1 -4
  85. package/dist/plugin/meta/ideExtension.js.map +1 -1
  86. package/dist/plugin/schema.js +1 -4
  87. package/dist/plugin/schema.js.map +1 -1
  88. package/dist/project/api.js +1 -4
  89. package/dist/project/api.js.map +1 -1
  90. package/dist/project/loadProject.d.ts.map +1 -1
  91. package/dist/project/loadProject.js +1 -6
  92. package/dist/project/loadProject.js.map +1 -1
  93. package/dist/project/loadProject.test.js +1 -4
  94. package/dist/project/loadProject.test.js.map +1 -1
  95. package/dist/project/loadProjectFromDirectory.js +1 -4
  96. package/dist/project/loadProjectFromDirectory.js.map +1 -1
  97. package/dist/project/loadProjectFromDirectory.test.js +1 -4
  98. package/dist/project/loadProjectFromDirectory.test.js.map +1 -1
  99. package/dist/project/loadProjectInMemory.js +1 -4
  100. package/dist/project/loadProjectInMemory.js.map +1 -1
  101. package/dist/project/loadProjectInMemory.test.js +1 -4
  102. package/dist/project/loadProjectInMemory.test.js.map +1 -1
  103. package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -1
  104. package/dist/project/maybeCaptureTelemetry.js +1 -6
  105. package/dist/project/maybeCaptureTelemetry.js.map +1 -1
  106. package/dist/project/maybeCaptureTelemetry.test.js +1 -4
  107. package/dist/project/maybeCaptureTelemetry.test.js.map +1 -1
  108. package/dist/project/newProject.d.ts.map +1 -1
  109. package/dist/project/newProject.js +1 -6
  110. package/dist/project/newProject.js.map +1 -1
  111. package/dist/project/newProject.test.js +1 -4
  112. package/dist/project/newProject.test.js.map +1 -1
  113. package/dist/project/saveProjectToDirectory.d.ts.map +1 -1
  114. package/dist/project/saveProjectToDirectory.js +17 -17
  115. package/dist/project/saveProjectToDirectory.js.map +1 -1
  116. package/dist/project/saveProjectToDirectory.test.js +40 -4
  117. package/dist/project/saveProjectToDirectory.test.js.map +1 -1
  118. package/dist/query-utilities/index.js +1 -4
  119. package/dist/query-utilities/index.js.map +1 -1
  120. package/dist/query-utilities/insertBundleNested.js +1 -4
  121. package/dist/query-utilities/insertBundleNested.js.map +1 -1
  122. package/dist/query-utilities/selectBundleNested.js +1 -4
  123. package/dist/query-utilities/selectBundleNested.js.map +1 -1
  124. package/dist/query-utilities/updateBundleNested.js +1 -4
  125. package/dist/query-utilities/updateBundleNested.js.map +1 -1
  126. package/dist/query-utilities/upsertBundleNested.js +1 -4
  127. package/dist/query-utilities/upsertBundleNested.js.map +1 -1
  128. package/dist/services/env-variables/index.js +2 -5
  129. package/dist/services/env-variables/index.js.map +1 -1
  130. package/dist/services/telemetry/capture.d.ts.map +1 -1
  131. package/dist/services/telemetry/capture.js +5 -9
  132. package/dist/services/telemetry/capture.js.map +1 -1
  133. package/dist/services/telemetry/capture.test.js +1 -4
  134. package/dist/services/telemetry/capture.test.js.map +1 -1
  135. package/dist/utilities/detectJsonFormatting.js +1 -4
  136. package/dist/utilities/detectJsonFormatting.js.map +1 -1
  137. package/dist/utilities/detectJsonFormatting.test.js +1 -4
  138. package/dist/utilities/detectJsonFormatting.test.js.map +1 -1
  139. package/package.json +2 -6
  140. package/src/plugin/importPlugins.ts +11 -5
  141. package/src/project/loadProject.ts +0 -3
  142. package/src/project/maybeCaptureTelemetry.ts +0 -2
  143. package/src/project/newProject.ts +0 -2
  144. package/src/project/saveProjectToDirectory.test.ts +41 -0
  145. package/src/project/saveProjectToDirectory.ts +16 -14
  146. package/src/services/telemetry/capture.ts +4 -5
  147. package/dist/project/initHandleSaveToLixOnChange.d.ts +0 -14
  148. package/dist/project/initHandleSaveToLixOnChange.d.ts.map +0 -1
  149. package/dist/project/initHandleSaveToLixOnChange.js +0 -87
  150. package/dist/project/initHandleSaveToLixOnChange.js.map +0 -1
  151. package/dist/services/error-reporting/index.d.ts +0 -15
  152. package/dist/services/error-reporting/index.d.ts.map +0 -1
  153. package/dist/services/error-reporting/index.js +0 -30
  154. package/dist/services/error-reporting/index.js.map +0 -1
  155. package/src/services/error-reporting/index.ts +0 -28
@@ -1 +1 @@
1
- {"version":3,"file":"upsertBundleNested.js","sources":["query-utilities/upsertBundleNested.ts"],"sourceRoot":"/","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type {\n\tInlangDatabaseSchema,\n\tNewBundleNested,\n} from \"../database/schema.js\";\n\nexport const upsertBundleNested = async (\n\tdb: Kysely<InlangDatabaseSchema>,\n\tbundle: NewBundleNested\n): Promise<void> => {\n\tawait db.transaction().execute(async (trx) => {\n\t\tconst insertedBundle = await trx\n\t\t\t.insertInto(\"bundle\")\n\t\t\t.values({\n\t\t\t\tid: bundle.id,\n\t\t\t\tdeclarations: bundle.declarations,\n\t\t\t})\n\t\t\t.returning(\"id\")\n\t\t\t.onConflict((oc) =>\n\t\t\t\toc.column(\"id\").doUpdateSet({\n\t\t\t\t\t...bundle,\n\t\t\t\t\t// @ts-expect-error - undefined\n\t\t\t\t\tmessages: undefined,\n\t\t\t\t})\n\t\t\t)\n\t\t\t.executeTakeFirstOrThrow();\n\n\t\tfor (const message of bundle.messages) {\n\t\t\tconst insertedMessage = await trx\n\t\t\t\t.insertInto(\"message\")\n\t\t\t\t.values({\n\t\t\t\t\tid: message.id,\n\t\t\t\t\tbundleId: insertedBundle.id,\n\t\t\t\t\tlocale: message.locale,\n\t\t\t\t\tselectors: message.selectors,\n\t\t\t\t})\n\t\t\t\t.onConflict((oc) =>\n\t\t\t\t\toc.column(\"id\").doUpdateSet({\n\t\t\t\t\t\t...message,\n\t\t\t\t\t\t// @ts-expect-error - undefined\n\t\t\t\t\t\tvariants: undefined,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.returning(\"id\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tfor (const variant of message.variants) {\n\t\t\t\tawait trx\n\t\t\t\t\t.insertInto(\"variant\")\n\t\t\t\t\t.values({\n\t\t\t\t\t\tid: variant.id,\n\t\t\t\t\t\tmessageId: insertedMessage.id,\n\t\t\t\t\t\tmatches: variant.matches,\n\t\t\t\t\t\tpattern: variant.pattern,\n\t\t\t\t\t})\n\t\t\t\t\t.onConflict((oc) => oc.column(\"id\").doUpdateSet(variant))\n\t\t\t\t\t.execute();\n\t\t\t}\n\t\t}\n\t});\n};\n"],"names":[],"mappings":";;AAMA,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACtC,EAAgC,EAChC,MAAuB,EACP,EAAE;IAClB,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC5C,MAAM,cAAc,GAAG,MAAM,GAAG;aAC9B,UAAU,CAAC,QAAQ,CAAC;aACpB,MAAM,CAAC;YACP,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,YAAY,EAAE,MAAM,CAAC,YAAY;SACjC,CAAC;aACD,SAAS,CAAC,IAAI,CAAC;aACf,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAClB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;YAC3B,GAAG,MAAM;YACT,+BAA+B;YAC/B,QAAQ,EAAE,SAAS;SACnB,CAAC,CACF;aACA,uBAAuB,EAAE,CAAC;QAE5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,eAAe,GAAG,MAAM,GAAG;iBAC/B,UAAU,CAAC,SAAS,CAAC;iBACrB,MAAM,CAAC;gBACP,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,QAAQ,EAAE,cAAc,CAAC,EAAE;gBAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,SAAS,EAAE,OAAO,CAAC,SAAS;aAC5B,CAAC;iBACD,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAClB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;gBAC3B,GAAG,OAAO;gBACV,+BAA+B;gBAC/B,QAAQ,EAAE,SAAS;aACnB,CAAC,CACF;iBACA,SAAS,CAAC,IAAI,CAAC;iBACf,uBAAuB,EAAE,CAAC;YAE5B,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACxC,MAAM,GAAG;qBACP,UAAU,CAAC,SAAS,CAAC;qBACrB,MAAM,CAAC;oBACP,EAAE,EAAE,OAAO,CAAC,EAAE;oBACd,SAAS,EAAE,eAAe,CAAC,EAAE;oBAC7B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;iBACxB,CAAC;qBACD,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;qBACxD,OAAO,EAAE,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","debug_id":"a56f9bf0-536e-55e4-80e5-59a5fc5e8e9e"}
1
+ {"version":3,"file":"upsertBundleNested.js","sourceRoot":"/","sources":["query-utilities/upsertBundleNested.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACtC,EAAgC,EAChC,MAAuB,EACP,EAAE;IAClB,MAA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AC7B,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;iBACxB,CAAC;qBACD,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;qBACxD,OAAO,EAAE,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Kysely } from \"kysely\";\nimport type {\n\tInlangDatabaseSchema,\n\tNewBundleNested,\n} from \"../database/schema.js\";\n\nexport const upsertBundleNested = async (\n\tdb: Kysely<InlangDatabaseSchema>,\n\tbundle: NewBundleNested\n): Promise<void> => {\n\tawait db.transaction().execute(async (trx) => {\n\t\tconst insertedBundle = await trx\n\t\t\t.insertInto(\"bundle\")\n\t\t\t.values({\n\t\t\t\tid: bundle.id,\n\t\t\t\tdeclarations: bundle.declarations,\n\t\t\t})\n\t\t\t.returning(\"id\")\n\t\t\t.onConflict((oc) =>\n\t\t\t\toc.column(\"id\").doUpdateSet({\n\t\t\t\t\t...bundle,\n\t\t\t\t\t// @ts-expect-error - undefined\n\t\t\t\t\tmessages: undefined,\n\t\t\t\t})\n\t\t\t)\n\t\t\t.executeTakeFirstOrThrow();\n\n\t\tfor (const message of bundle.messages) {\n\t\t\tconst insertedMessage = await trx\n\t\t\t\t.insertInto(\"message\")\n\t\t\t\t.values({\n\t\t\t\t\tid: message.id,\n\t\t\t\t\tbundleId: insertedBundle.id,\n\t\t\t\t\tlocale: message.locale,\n\t\t\t\t\tselectors: message.selectors,\n\t\t\t\t})\n\t\t\t\t.onConflict((oc) =>\n\t\t\t\t\toc.column(\"id\").doUpdateSet({\n\t\t\t\t\t\t...message,\n\t\t\t\t\t\t// @ts-expect-error - undefined\n\t\t\t\t\t\tvariants: undefined,\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.returning(\"id\")\n\t\t\t\t.executeTakeFirstOrThrow();\n\n\t\t\tfor (const variant of message.variants) {\n\t\t\t\tawait trx\n\t\t\t\t\t.insertInto(\"variant\")\n\t\t\t\t\t.values({\n\t\t\t\t\t\tid: variant.id,\n\t\t\t\t\t\tmessageId: insertedMessage.id,\n\t\t\t\t\t\tmatches: variant.matches,\n\t\t\t\t\t\tpattern: variant.pattern,\n\t\t\t\t\t})\n\t\t\t\t\t.onConflict((oc) => oc.column(\"id\").doUpdateSet(variant))\n\t\t\t\t\t.execute();\n\t\t\t}\n\t\t}\n\t});\n};\n"]}
@@ -1,9 +1,6 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="799e7ff6-764a-5b13-80d1-632e9723e900")}catch(e){}}();
3
1
  export const ENV_VARIABLES = {
4
2
  PUBLIC_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz",
5
3
  PUBLIC_INLANG_SDK_SENTRY_DSN: "https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553",
6
- SDK_VERSION: "2.1.3",
4
+ SDK_VERSION: "2.2.1",
7
5
  };
8
- //# sourceMappingURL=index.js.map
9
- //# debugId=799e7ff6-764a-5b13-80d1-632e9723e900
6
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["services/env-variables/index.ts"],"sourceRoot":"/","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: \"phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz\",\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: \"https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553\",\n\tSDK_VERSION: \"2.1.3\",\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,iDAAiD;IACxE,4BAA4B,EAAE,iGAAiG;IAC/H,WAAW,EAAE,OAAO;CACpB,CAAA","debug_id":"799e7ff6-764a-5b13-80d1-632e9723e900"}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,oBAAoB,EAAE,iDAAiD;IACxE,4BAA4B,EAAE,iGAAiG;IAC/H,WAAW,EAAE,OAAO;CACpB,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n PUBLIC_POSTHOG_TOKEN: \"phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz\",\n\tPUBLIC_INLANG_SDK_SENTRY_DSN: \"https://c3d92d5d011122e525e9f9b368e0905d@o4504345873285120.ingest.us.sentry.io/4507903389335553\",\n\tSDK_VERSION: \"2.2.1\",\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"capture.d.ts","sourceRoot":"/","sources":["services/telemetry/capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAIrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,oBAAoB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,UACZ,cAAc,QACf;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;CAC7C,kBA8BD,CAAC"}
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"/","sources":["services/telemetry/capture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE;;;;;GAKG;AACH,KAAK,cAAc,GAAG,oBAAoB,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,UACZ,cAAc,QACf;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;CAC7C,kBA8BD,CAAC"}
@@ -1,8 +1,5 @@
1
1
  // import { ENV_VARIABLES } from "../env-variables/index.js";
2
-
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4a83d392-5cb6-5c43-9098-5708dd6509bb")}catch(e){}}();
4
2
  import { ENV_VARIABLES } from "../env-variables/index.js";
5
- import { captureError } from "../error-reporting/index.js";
6
3
  /**
7
4
  * Capture an event.
8
5
  *
@@ -36,8 +33,8 @@ export const capture = async (event, args) => {
36
33
  properties: { name: args.projectId },
37
34
  });
38
35
  }
39
- catch (e) {
40
- captureError(e);
36
+ catch {
37
+ // do nothing
41
38
  }
42
39
  };
43
40
  /**
@@ -68,9 +65,8 @@ const identifyProject = async (args) => {
68
65
  }),
69
66
  });
70
67
  }
71
- catch (e) {
72
- captureError(e);
68
+ catch {
69
+ // do nothing
73
70
  }
74
71
  };
75
- //# sourceMappingURL=capture.js.map
76
- //# debugId=4a83d392-5cb6-5c43-9098-5708dd6509bb
72
+ //# sourceMappingURL=capture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"capture.js","sources":["services/telemetry/capture.ts"],"sourceRoot":"/","sourcesContent":["// import { ENV_VARIABLES } from \"../env-variables/index.js\";\n\nimport type { ProjectSettings } from \"../../json-schema/settings.js\";\nimport { ENV_VARIABLES } from \"../env-variables/index.js\";\nimport { captureError } from \"../error-reporting/index.js\";\n\n/**\n * List of telemetry events for typesafety.\n *\n * - prefix with `SDK` to avoid collisions with other apps\n * - use past tense to indicate that the event is completed\n */\ntype TelemetryEvent = \"SDK loaded project\";\n\n/**\n * Capture an event.\n *\n * - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)\n */\nexport const capture = async (\n\tevent: TelemetryEvent,\n\targs: {\n\t\tprojectId: string;\n\t\taccountId: string;\n\t\t/**\n\t\t * Please use snake_case for property names.\n\t\t */\n\t\tproperties: Record<string, any>;\n\t\tsettings: Pick<ProjectSettings, \"telemetry\">;\n\t}\n) => {\n\tif (args.settings.telemetry === \"off\") {\n\t\treturn;\n\t} else if (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait fetch(\"https://eu.posthog.com/capture/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapi_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,\n\t\t\t\tevent,\n\t\t\t\tdistinct_id: args.accountId,\n\t\t\t\tproperties: {\n\t\t\t\t\t$groups: { project: args.projectId },\n\t\t\t\t\t...args.properties,\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t\tawait identifyProject({\n\t\t\tprojectId: args.projectId,\n\t\t\taccountId: args.accountId,\n\t\t\t// using the id for now as a name but can be changed in the future\n\t\t\t// we need at least one property to make a project visible in the dashboar\n\t\t\tproperties: { name: args.projectId },\n\t\t});\n\t} catch (e) {\n\t\tcaptureError(e);\n\t}\n};\n\n/**\n * Identifying a project is needed.\n *\n * Otherwise, the project will not be visible in the PostHog dashboard.\n */\nconst identifyProject = async (args: {\n\tprojectId: string;\n\taccountId: string;\n\t/**\n\t * Please use snake_case for property names.\n\t */\n\tproperties: Record<string, any>;\n}) => {\n\t// do not send events if the token is not set\n\t// (assuming this eases testing)\n\tif (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait fetch(\"https://eu.posthog.com/capture/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapi_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,\n\t\t\t\tevent: \"$groupidentify\",\n\t\t\t\tdistinct_id: args.accountId,\n\t\t\t\tproperties: {\n\t\t\t\t\t$group_type: \"project\",\n\t\t\t\t\t$group_key: args.projectId,\n\t\t\t\t\t$group_set: {\n\t\t\t\t\t\t...args.properties,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t} catch (e) {\n\t\tcaptureError(e);\n\t}\n};\n"],"names":[],"mappings":"AAAA,6DAA6D;;;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAU3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC3B,KAAqB,EACrB,IAQC,EACA,EAAE;IACH,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QACvC,OAAO;IACR,CAAC;SAAM,IAAI,aAAa,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO;IACR,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,iCAAiC,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,OAAO,EAAE,aAAa,CAAC,oBAAoB;gBAC3C,KAAK;gBACL,WAAW,EAAE,IAAI,CAAC,SAAS;gBAC3B,UAAU,EAAE;oBACX,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE;oBACpC,GAAG,IAAI,CAAC,UAAU;iBAClB;aACD,CAAC;SACF,CAAC,CAAC;QACH,MAAM,eAAe,CAAC;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,kEAAkE;YAClE,0EAA0E;YAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;SACpC,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,YAAY,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,IAO9B,EAAE,EAAE;IACJ,6CAA6C;IAC7C,gCAAgC;IAChC,IAAI,aAAa,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO;IACR,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,KAAK,CAAC,iCAAiC,EAAE;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,OAAO,EAAE,aAAa,CAAC,oBAAoB;gBAC3C,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EAAE,IAAI,CAAC,SAAS;gBAC3B,UAAU,EAAE;oBACX,WAAW,EAAE,SAAS;oBACtB,UAAU,EAAE,IAAI,CAAC,SAAS;oBAC1B,UAAU,EAAE;wBACX,GAAG,IAAI,CAAC,UAAU;qBAClB;iBACD;aACD,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,YAAY,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC,CAAC","debug_id":"4a83d392-5cb6-5c43-9098-5708dd6509bb"}
1
+ {"version":3,"file":"capture.js","sourceRoot":"/","sources":["services/telemetry/capture.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAU1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC3B,KAAqB,EACrB,IAQC,EACA,EAAE;IACH,IAAI,I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,SAAS;oBACtB,UAAU,EAAE,IAAI,CAAC,SAAS;oBAC1B,UAAU,EAAE;wBACX,GAAG,IAAI,CAAC,UAAU;qBAClB;iBACD;aACD,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,aAAa;IACd,CAAC;AACF,CAAC,CAAC","sourcesContent":["// import { ENV_VARIABLES } from \"../env-variables/index.js\";\n\nimport type { ProjectSettings } from \"../../json-schema/settings.js\";\nimport { ENV_VARIABLES } from \"../env-variables/index.js\";\n\n/**\n * List of telemetry events for typesafety.\n *\n * - prefix with `SDK` to avoid collisions with other apps\n * - use past tense to indicate that the event is completed\n */\ntype TelemetryEvent = \"SDK loaded project\";\n\n/**\n * Capture an event.\n *\n * - manually calling the PostHog API because the SDKs were not platform angostic (and generally bloated)\n */\nexport const capture = async (\n\tevent: TelemetryEvent,\n\targs: {\n\t\tprojectId: string;\n\t\taccountId: string;\n\t\t/**\n\t\t * Please use snake_case for property names.\n\t\t */\n\t\tproperties: Record<string, any>;\n\t\tsettings: Pick<ProjectSettings, \"telemetry\">;\n\t}\n) => {\n\tif (args.settings.telemetry === \"off\") {\n\t\treturn;\n\t} else if (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait fetch(\"https://eu.posthog.com/capture/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapi_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,\n\t\t\t\tevent,\n\t\t\t\tdistinct_id: args.accountId,\n\t\t\t\tproperties: {\n\t\t\t\t\t$groups: { project: args.projectId },\n\t\t\t\t\t...args.properties,\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t\tawait identifyProject({\n\t\t\tprojectId: args.projectId,\n\t\t\taccountId: args.accountId,\n\t\t\t// using the id for now as a name but can be changed in the future\n\t\t\t// we need at least one property to make a project visible in the dashboar\n\t\t\tproperties: { name: args.projectId },\n\t\t});\n\t} catch {\n\t\t// do nothing\n\t}\n};\n\n/**\n * Identifying a project is needed.\n *\n * Otherwise, the project will not be visible in the PostHog dashboard.\n */\nconst identifyProject = async (args: {\n\tprojectId: string;\n\taccountId: string;\n\t/**\n\t * Please use snake_case for property names.\n\t */\n\tproperties: Record<string, any>;\n}) => {\n\t// do not send events if the token is not set\n\t// (assuming this eases testing)\n\tif (ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN === undefined) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait fetch(\"https://eu.posthog.com/capture/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapi_key: ENV_VARIABLES.PUBLIC_POSTHOG_TOKEN,\n\t\t\t\tevent: \"$groupidentify\",\n\t\t\t\tdistinct_id: args.accountId,\n\t\t\t\tproperties: {\n\t\t\t\t\t$group_type: \"project\",\n\t\t\t\t\t$group_key: args.projectId,\n\t\t\t\t\t$group_set: {\n\t\t\t\t\t\t...args.properties,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t});\n\t} catch {\n\t\t// do nothing\n\t}\n};\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="31b14236-b29d-51f6-a0ad-e9b7dd806439")}catch(e){}}();
3
1
  import { expect, test, vi } from "vitest";
4
2
  import { capture } from "./capture.js";
5
3
  test("it should not capture if telemetry is off", async () => {
@@ -42,5 +40,4 @@ test("it should not capture if telemetry is NOT off", async () => {
42
40
  });
43
41
  expect(global.fetch).toHaveBeenCalled();
44
42
  });
45
- //# sourceMappingURL=capture.test.js.map
46
- //# debugId=31b14236-b29d-51f6-a0ad-e9b7dd806439
43
+ //# sourceMappingURL=capture.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"capture.test.js","sources":["services/telemetry/capture.test.ts"],"sourceRoot":"/","sourcesContent":["import { expect, test, vi } from \"vitest\";\nimport { capture } from \"./capture.js\";\n\ntest(\"it should not capture if telemetry is off\", async () => {\n\t// @ts-expect-error - global.fetch is not defined\n\tglobal.fetch = vi.fn(() => Promise.resolve());\n\n\tvi.mock(\"../env-variables/index.js\", async () => {\n\t\treturn {\n\t\t\tENV_VARIABLES: {\n\t\t\t\tPUBLIC_POSTHOG_TOKEN: \"mock-defined\",\n\t\t\t},\n\t\t};\n\t});\n\n\tawait capture(\"SDK loaded project\", {\n\t\tprojectId: \"test\",\n\t\taccountId: \"test\",\n\t\tsettings: {\n\t\t\ttelemetry: \"off\",\n\t\t},\n\t\tproperties: {},\n\t});\n\n\texpect(global.fetch).not.toHaveBeenCalled();\n});\n\ntest(\"it should not capture if telemetry is NOT off\", async () => {\n\t// @ts-expect-error - global.fetch is not defined\n\tglobal.fetch = vi.fn(() => Promise.resolve());\n\n\tvi.mock(\"../env-variables/index.js\", async () => {\n\t\treturn {\n\t\t\tENV_VARIABLES: {\n\t\t\t\tPUBLIC_POSTHOG_TOKEN: \"mock-defined\",\n\t\t\t},\n\t\t};\n\t});\n\n\tawait capture(\"SDK loaded project\", {\n\t\tprojectId: \"test\",\n\t\taccountId: \"test\",\n\t\tsettings: {\n\t\t\ttelemetry: undefined,\n\t\t},\n\t\tproperties: {},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalled();\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,IAAI,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IAC5D,iDAAiD;IACjD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9C,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC/C,OAAO;YACN,aAAa,EAAE;gBACd,oBAAoB,EAAE,cAAc;aACpC;SACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,oBAAoB,EAAE;QACnC,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE;YACT,SAAS,EAAE,KAAK;SAChB;QACD,UAAU,EAAE,EAAE;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;IAChE,iDAAiD;IACjD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9C,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC/C,OAAO;YACN,aAAa,EAAE;gBACd,oBAAoB,EAAE,cAAc;aACpC;SACD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,oBAAoB,EAAE;QACnC,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE;YACT,SAAS,EAAE,SAAS;SACpB;QACD,UAAU,EAAE,EAAE;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACzC,CAAC,CAAC,CAAC","debug_id":"31b14236-b29d-51f6-a0ad-e9b7dd806439"}
1
+ {"version":3,"file":"capture.test.js","sourceRoot":"/","sources":["services/telemetry/capture.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO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AC,CAAC","sourcesContent":["import { expect, test, vi } from \"vitest\";\nimport { capture } from \"./capture.js\";\n\ntest(\"it should not capture if telemetry is off\", async () => {\n\t// @ts-expect-error - global.fetch is not defined\n\tglobal.fetch = vi.fn(() => Promise.resolve());\n\n\tvi.mock(\"../env-variables/index.js\", async () => {\n\t\treturn {\n\t\t\tENV_VARIABLES: {\n\t\t\t\tPUBLIC_POSTHOG_TOKEN: \"mock-defined\",\n\t\t\t},\n\t\t};\n\t});\n\n\tawait capture(\"SDK loaded project\", {\n\t\tprojectId: \"test\",\n\t\taccountId: \"test\",\n\t\tsettings: {\n\t\t\ttelemetry: \"off\",\n\t\t},\n\t\tproperties: {},\n\t});\n\n\texpect(global.fetch).not.toHaveBeenCalled();\n});\n\ntest(\"it should not capture if telemetry is NOT off\", async () => {\n\t// @ts-expect-error - global.fetch is not defined\n\tglobal.fetch = vi.fn(() => Promise.resolve());\n\n\tvi.mock(\"../env-variables/index.js\", async () => {\n\t\treturn {\n\t\t\tENV_VARIABLES: {\n\t\t\t\tPUBLIC_POSTHOG_TOKEN: \"mock-defined\",\n\t\t\t},\n\t\t};\n\t});\n\n\tawait capture(\"SDK loaded project\", {\n\t\tprojectId: \"test\",\n\t\taccountId: \"test\",\n\t\tsettings: {\n\t\t\ttelemetry: undefined,\n\t\t},\n\t\tproperties: {},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalled();\n});\n"]}
@@ -7,8 +7,6 @@
7
7
  * const stringify = detectJsonFormatting(file)
8
8
  * const newFile = stringify(json)
9
9
  */
10
-
11
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="73442250-e5ab-565c-bf3d-a05914aa2cce")}catch(e){}}();
12
10
  export const detectJsonFormatting = (file) => {
13
11
  const endsWithNewLine = file.endsWith("\n");
14
12
  const spacing = guessJsonIndent(file);
@@ -79,5 +77,4 @@ const normalizeIndent = (indent) => {
79
77
  }
80
78
  return indent[0] === " " ? indent.length : indent;
81
79
  };
82
- //# sourceMappingURL=detectJsonFormatting.js.map
83
- //# debugId=73442250-e5ab-565c-bf3d-a05914aa2cce
80
+ //# sourceMappingURL=detectJsonFormatting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectJsonFormatting.js","sources":["utilities/detectJsonFormatting.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Detects the formatting of a JSON file and returns a function\n * that can be used to stringify JSON with the same formatting.\n *\n * @example\n * const file = await fs.readFile(\"./messages.json\", { encoding: \"utf-8\" })\n * const stringify = detectJsonFormatting(file)\n * const newFile = stringify(json)\n */\nexport const detectJsonFormatting = (\n\tfile: string\n): ((\n\tvalue: Parameters<typeof JSON.stringify>[0],\n\treplacer?: Parameters<typeof JSON.stringify>[1]\n\t// space is provided by the function\n) => string) => {\n\tconst endsWithNewLine = file.endsWith(\"\\n\");\n\tconst spacing = guessJsonIndent(file);\n\n\treturn (value, replacer) =>\n\t\tJSON.stringify(value, replacer, spacing as any) +\n\t\t(endsWithNewLine ? \"\\n\" : \"\");\n};\n\n/**\n * vendored from https://github.com/ehmicky/guess-json-indent\n */\n// Guess the indentation of a JSON string\nconst guessJsonIndent = (jsonString: string) => {\n\tconst firstIndex = skipWhitespaces(jsonString, 0);\n\n\tif (\n\t\tfirstIndex === undefined ||\n\t\t!isJsonObjectOrArray(jsonString[firstIndex])\n\t) {\n\t\treturn;\n\t}\n\n\tconst secondIndex = skipWhitespaces(jsonString, firstIndex + 1);\n\n\tif (secondIndex === undefined) {\n\t\treturn;\n\t}\n\n\treturn getIndent(jsonString, firstIndex, secondIndex);\n};\n\n// Whitespaces are ignored before|between|after tokens in JSON.\n// Uses imperative logic for performance.\nconst skipWhitespaces = (jsonString: string | any[], startIndex: number) => {\n\tfor (let index = startIndex; index < jsonString.length; index += 1) {\n\t\tconst character = jsonString[index];\n\n\t\tif (!isJsonWhitespace(character)) {\n\t\t\treturn index;\n\t\t}\n\t}\n\treturn;\n};\n\n// JSON defines only those are valid whitespaces\nconst isJsonWhitespace = (character: string) =>\n\tcharacter === \" \" ||\n\tcharacter === \"\\t\" ||\n\tcharacter === \"\\n\" ||\n\tcharacter === \"\\r\";\n\n// If the top-level value is another type than an object or an array, there is\n// no possible indentation\nconst isJsonObjectOrArray = (character: string | undefined) =>\n\tcharacter === \"{\" || character === \"[\";\n\n// Uses imperative logic for performance\n// @ts-expect-error - not all code paths return a value\nconst getIndent = (\n\tjsonString: string | any[],\n\tfirstIndex: number,\n\tsecondIndex: number\n) => {\n\tlet indent;\n\n\tfor (let index = secondIndex - 1; index > firstIndex; index -= 1) {\n\t\tconst character = jsonString[index];\n\n\t\tif (character === \"\\r\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (character === \"\\n\") {\n\t\t\treturn normalizeIndent(indent);\n\t\t}\n\n\t\tif (indent === undefined) {\n\t\t\tindent = character;\n\t\t} else if (indent[0] === character) {\n\t\t\tindent += character;\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t}\n};\n\nconst normalizeIndent = (indent: string | any[] | undefined) => {\n\tif (indent === undefined) {\n\t\treturn 0;\n\t}\n\n\treturn indent[0] === \" \" ? indent.length : indent;\n};\n"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,IAAY,EAKA,EAAE;IACd,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC1B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAc,CAAC;QAC/C,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;GAEG;AACH,yCA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EAC1B,UAAkB,EAClB,WAAmB,EAClB,EAAE;IACH,IAAI,MAAM,CAAC;IAEX,KAAK,IAAI,KAAK,GAAG,WAAW,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO;QACR,CAAC;QAED,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,GAAG,SAAS,CAAC;QACpB,CAAC;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,OAAO;QACR,CAAC;IACF,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,MAAkC,EAAE,EAAE;IAC9D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC,CAAC","debug_id":"73442250-e5ab-565c-bf3d-a05914aa2cce"}
1
+ {"version":3,"file":"detectJsonFormatting.js","sourceRoot":"/","sources":["utilities/detectJsonFormatting.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,IAAY,EAKA,EAAE;IACd,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtC,OAA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AS,KAAK,IAAI,CAAC;AAEpB,8EAA8E;AAC9E,0BAA0B;AAC1B,MAAM,mBAAmB,GAAG,CAAC,SAA6B,EAAE,EAAE,CAC7D,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,CAAC;AAExC,wCAAwC;AACxC,uDAAuD;AACvD,MAAM,SAAS,GAAG,CACjB,UAA0B,EAC1B,UAAkB,EAClB,WAAmB,EAClB,EAAE;IACH,IAAI,MAAM,CAAC;IAEX,KAAK,IAAI,KAAK,GAAG,WAAW,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO;QACR,CAAC;QAED,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,GAAG,SAAS,CAAC;QACpB,CAAC;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,OAAO;QACR,CAAC;IACF,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,MAAkC,EAAE,EAAE;IAC9D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/**\n * Detects the formatting of a JSON file and returns a function\n * that can be used to stringify JSON with the same formatting.\n *\n * @example\n * const file = await fs.readFile(\"./messages.json\", { encoding: \"utf-8\" })\n * const stringify = detectJsonFormatting(file)\n * const newFile = stringify(json)\n */\nexport const detectJsonFormatting = (\n\tfile: string\n): ((\n\tvalue: Parameters<typeof JSON.stringify>[0],\n\treplacer?: Parameters<typeof JSON.stringify>[1]\n\t// space is provided by the function\n) => string) => {\n\tconst endsWithNewLine = file.endsWith(\"\\n\");\n\tconst spacing = guessJsonIndent(file);\n\n\treturn (value, replacer) =>\n\t\tJSON.stringify(value, replacer, spacing as any) +\n\t\t(endsWithNewLine ? \"\\n\" : \"\");\n};\n\n/**\n * vendored from https://github.com/ehmicky/guess-json-indent\n */\n// Guess the indentation of a JSON string\nconst guessJsonIndent = (jsonString: string) => {\n\tconst firstIndex = skipWhitespaces(jsonString, 0);\n\n\tif (\n\t\tfirstIndex === undefined ||\n\t\t!isJsonObjectOrArray(jsonString[firstIndex])\n\t) {\n\t\treturn;\n\t}\n\n\tconst secondIndex = skipWhitespaces(jsonString, firstIndex + 1);\n\n\tif (secondIndex === undefined) {\n\t\treturn;\n\t}\n\n\treturn getIndent(jsonString, firstIndex, secondIndex);\n};\n\n// Whitespaces are ignored before|between|after tokens in JSON.\n// Uses imperative logic for performance.\nconst skipWhitespaces = (jsonString: string | any[], startIndex: number) => {\n\tfor (let index = startIndex; index < jsonString.length; index += 1) {\n\t\tconst character = jsonString[index];\n\n\t\tif (!isJsonWhitespace(character)) {\n\t\t\treturn index;\n\t\t}\n\t}\n\treturn;\n};\n\n// JSON defines only those are valid whitespaces\nconst isJsonWhitespace = (character: string) =>\n\tcharacter === \" \" ||\n\tcharacter === \"\\t\" ||\n\tcharacter === \"\\n\" ||\n\tcharacter === \"\\r\";\n\n// If the top-level value is another type than an object or an array, there is\n// no possible indentation\nconst isJsonObjectOrArray = (character: string | undefined) =>\n\tcharacter === \"{\" || character === \"[\";\n\n// Uses imperative logic for performance\n// @ts-expect-error - not all code paths return a value\nconst getIndent = (\n\tjsonString: string | any[],\n\tfirstIndex: number,\n\tsecondIndex: number\n) => {\n\tlet indent;\n\n\tfor (let index = secondIndex - 1; index > firstIndex; index -= 1) {\n\t\tconst character = jsonString[index];\n\n\t\tif (character === \"\\r\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (character === \"\\n\") {\n\t\t\treturn normalizeIndent(indent);\n\t\t}\n\n\t\tif (indent === undefined) {\n\t\t\tindent = character;\n\t\t} else if (indent[0] === character) {\n\t\t\tindent += character;\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\t}\n};\n\nconst normalizeIndent = (indent: string | any[] | undefined) => {\n\tif (indent === undefined) {\n\t\treturn 0;\n\t}\n\n\treturn indent[0] === \" \" ? indent.length : indent;\n};\n"]}
@@ -1,5 +1,3 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eed11d62-4499-5c30-9d3e-f2787865c751")}catch(e){}}();
3
1
  import { expect, it } from "vitest";
4
2
  import { detectJsonFormatting } from "./detectJsonFormatting.js";
5
3
  it("should detect spacing", () => {
@@ -29,5 +27,4 @@ it("should detect new lines correctly", () => {
29
27
  expect(serialize2(JSON.parse(withoutNewLine))).toBe(withoutNewLine);
30
28
  expect(serialize3(JSON.parse(withNewLineAndSpacing))).toBe(withNewLineAndSpacing);
31
29
  });
32
- //# sourceMappingURL=detectJsonFormatting.test.js.map
33
- //# debugId=eed11d62-4499-5c30-9d3e-f2787865c751
30
+ //# sourceMappingURL=detectJsonFormatting.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectJsonFormatting.test.js","sources":["utilities/detectJsonFormatting.test.ts"],"sourceRoot":"/","sourcesContent":["import { expect, it } from \"vitest\";\nimport { detectJsonFormatting } from \"./detectJsonFormatting.js\";\n\nit(\"should detect spacing\", () => {\n\t// test all possible spacings\n\tfor (const value of [1, 2, 3, 4, 6, 8, \"\\t\"]) {\n\t\tconst spacing = value === \"\\t\" ? \"\\t\" : \" \".repeat(value as number);\n\t\tconst objectWithSpacing = `{\\n${spacing}\"test\": \"test\"\\n}`;\n\n\t\tconst serialize = detectJsonFormatting(objectWithSpacing);\n\t\texpect(serialize(JSON.parse(objectWithSpacing))).toBe(objectWithSpacing);\n\t}\n});\n\nit(\"should detect spacing if the json is an array\", () => {\n\t// testing with one element only because dynamic generation of\n\t// arrays with different spacings is too complex\n\tconst objectWithSpacing = `[\\n\\t\"test\",\\n\\t\"test\"\\n]`;\n\n\tconst serialize = detectJsonFormatting(objectWithSpacing);\n\texpect(serialize(JSON.parse(objectWithSpacing))).toBe(objectWithSpacing);\n});\n\nit(\"should detect new lines correctly\", () => {\n\tconst withNewLine = `{\"test\":\"test\"}\\n`;\n\tconst withoutNewLine = `{\"test\":\"test\"}`;\n\tconst withNewLineAndSpacing = `{\\n\\t\"test\": \"test\"\\n}`;\n\n\tconst serialize1 = detectJsonFormatting(withNewLine);\n\tconst serialize2 = detectJsonFormatting(withoutNewLine);\n\tconst serialize3 = detectJsonFormatting(withNewLineAndSpacing);\n\n\texpect(serialize1(JSON.parse(withNewLine))).toBe(withNewLine);\n\texpect(serialize2(JSON.parse(withoutNewLine))).toBe(withoutNewLine);\n\texpect(serialize3(JSON.parse(withNewLineAndSpacing))).toBe(\n\t\twithNewLineAndSpacing\n\t);\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;IAChC,6BAA6B;IAC7B,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,C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AAC1E,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC5C,MAAM,WAAW,GAAG,mBAAmB,CAAC;IACxC,MAAM,cAAc,GAAG,iBAAiB,CAAC;IACzC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;IAEvD,MAAM,UAAU,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;IAE/D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACpE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI,CACzD,qBAAqB,CACrB,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { expect, it } from \"vitest\";\nimport { detectJsonFormatting } from \"./detectJsonFormatting.js\";\n\nit(\"should detect spacing\", () => {\n\t// test all possible spacings\n\tfor (const value of [1, 2, 3, 4, 6, 8, \"\\t\"]) {\n\t\tconst spacing = value === \"\\t\" ? \"\\t\" : \" \".repeat(value as number);\n\t\tconst objectWithSpacing = `{\\n${spacing}\"test\": \"test\"\\n}`;\n\n\t\tconst serialize = detectJsonFormatting(objectWithSpacing);\n\t\texpect(serialize(JSON.parse(objectWithSpacing))).toBe(objectWithSpacing);\n\t}\n});\n\nit(\"should detect spacing if the json is an array\", () => {\n\t// testing with one element only because dynamic generation of\n\t// arrays with different spacings is too complex\n\tconst objectWithSpacing = `[\\n\\t\"test\",\\n\\t\"test\"\\n]`;\n\n\tconst serialize = detectJsonFormatting(objectWithSpacing);\n\texpect(serialize(JSON.parse(objectWithSpacing))).toBe(objectWithSpacing);\n});\n\nit(\"should detect new lines correctly\", () => {\n\tconst withNewLine = `{\"test\":\"test\"}\\n`;\n\tconst withoutNewLine = `{\"test\":\"test\"}`;\n\tconst withNewLineAndSpacing = `{\\n\\t\"test\": \"test\"\\n}`;\n\n\tconst serialize1 = detectJsonFormatting(withNewLine);\n\tconst serialize2 = detectJsonFormatting(withoutNewLine);\n\tconst serialize3 = detectJsonFormatting(withNewLineAndSpacing);\n\n\texpect(serialize1(JSON.parse(withNewLine))).toBe(withNewLine);\n\texpect(serialize2(JSON.parse(withoutNewLine))).toBe(withoutNewLine);\n\texpect(serialize3(JSON.parse(withNewLineAndSpacing))).toBe(\n\t\twithNewLineAndSpacing\n\t);\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
- "version": "2.1.3",
3
+ "version": "2.2.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -26,7 +26,6 @@
26
26
  "node": ">=18.0.0"
27
27
  },
28
28
  "dependencies": {
29
- "@sentry/browser": "^7.118.0",
30
29
  "@sinclair/typebox": "^0.31.17",
31
30
  "kysely": "^0.27.4",
32
31
  "uuid": "^10.0.0",
@@ -35,7 +34,6 @@
35
34
  },
36
35
  "devDependencies": {
37
36
  "@eslint/js": "^9.12.0",
38
- "@sentry/cli": "^2.35.0",
39
37
  "@types/node": "^22.5.1",
40
38
  "@types/uuid": "^10.0.0",
41
39
  "@vitest/coverage-v8": "^2.0.5",
@@ -47,7 +45,6 @@
47
45
  "@opral/tsconfig": "1.1.0"
48
46
  },
49
47
  "scripts": {
50
- "prepublish": "npm run sentry:sourcemaps",
51
48
  "build": "npm run env-variables && tsc --build",
52
49
  "dev": "npm run env-variables && tsc --watch",
53
50
  "env-variables": "node ./src/services/env-variables/createIndexFile.js",
@@ -55,7 +52,6 @@
55
52
  "test:watch": "vitest",
56
53
  "lint": "eslint ./src",
57
54
  "format": "prettier ./src --write",
58
- "clean": "rm -rf ./dist ./node_modules",
59
- "sentry:sourcemaps": "sentry-cli sourcemaps inject --org opral --project inlang-sdk ./dist && sentry-cli sourcemaps upload --org opral --project inlang-sdk ./dist"
55
+ "clean": "rm -rf ./dist ./node_modules"
60
56
  }
61
57
  }
@@ -29,11 +29,17 @@ export async function importPlugins(args: {
29
29
  if (args.preprocessPluginBeforeImport) {
30
30
  moduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);
31
31
  }
32
- const moduleWithMimeType =
33
- "data:application/javascript," + encodeURIComponent(moduleAsText);
34
- const { default: module } = await import(
35
- /* @vite-ignore */ moduleWithMimeType
36
- );
32
+ let moduleAsURL;
33
+ if (process.versions.bun) {
34
+ // In bun we need to do dynamic imports differently
35
+ moduleAsURL = URL.createObjectURL(
36
+ new Blob([moduleAsText], { type: "text/javascript" })
37
+ );
38
+ } else {
39
+ // node and others
40
+ moduleAsURL = "data:text/javascript;base64," + btoa(moduleAsText);
41
+ }
42
+ const { default: module } = await import(/* @vite-ignore */ moduleAsURL);
37
43
  // old legacy message lint rules are not supported
38
44
  // and ingored for backwards compatibility
39
45
  if (module.id?.includes("messageLintRule")) {
@@ -13,7 +13,6 @@ import {
13
13
  import type { InlangProject } from "./api.js";
14
14
  import { withLanguageTagToLocaleMigration } from "../migrations/v2/withLanguageTagToLocaleMigration.js";
15
15
  import { v4 } from "uuid";
16
- import { initErrorReporting } from "../services/error-reporting/index.js";
17
16
  import { maybeCaptureLoadedProject } from "./maybeCaptureTelemetry.js";
18
17
  import { importFiles } from "../import-export/importFiles.js";
19
18
  import { exportFiles } from "../import-export/exportFiles.js";
@@ -110,8 +109,6 @@ export async function loadProject(args: {
110
109
  appId: args.appId,
111
110
  });
112
111
 
113
- initErrorReporting({ projectId: id });
114
-
115
112
  return {
116
113
  db,
117
114
  id: {
@@ -3,7 +3,6 @@ import { capture } from "../services/telemetry/capture.js";
3
3
  import type { InlangDatabaseSchema } from "../database/schema.js";
4
4
  import { ENV_VARIABLES } from "../services/env-variables/index.js";
5
5
  import type { ProjectSettings } from "../json-schema/settings.js";
6
- import { captureError } from "../services/error-reporting/index.js";
7
6
  import type { Lix } from "@lix-js/sdk";
8
7
 
9
8
  export async function maybeCaptureLoadedProject(args: {
@@ -64,6 +63,5 @@ export async function maybeCaptureLoadedProject(args: {
64
63
  // The project has been closed, nothing to capture
65
64
  return;
66
65
  }
67
- captureError(e);
68
66
  }
69
67
  }
@@ -6,7 +6,6 @@ import {
6
6
  createInMemoryDatabase,
7
7
  } from "sqlite-wasm-kysely";
8
8
  import { initDb } from "../database/initDb.js";
9
- import { captureError } from "../services/error-reporting/index.js";
10
9
 
11
10
  /**
12
11
  * Creates a new inlang project.
@@ -58,7 +57,6 @@ export async function newProject(args?: {
58
57
  const error = new Error(`Failed to create new inlang project: ${e}`, {
59
58
  cause: e,
60
59
  });
61
- captureError(error);
62
60
  throw error;
63
61
  } finally {
64
62
  sqlite.close();
@@ -328,3 +328,44 @@ test("adds a gitignore file if it doesn't exist", async () => {
328
328
  );
329
329
  expect(gitignore).toBe("cache");
330
330
  });
331
+
332
+ test("uses exportFiles when both exportFiles and saveMessages are defined", async () => {
333
+ const exportFilesSpy = vi.fn().mockResolvedValue([]);
334
+ const saveMessagesSpy = vi.fn();
335
+ const mockPlugin: InlangPlugin = {
336
+ key: "mock",
337
+ exportFiles: exportFilesSpy,
338
+ saveMessages: saveMessagesSpy,
339
+ };
340
+ const volume = Volume.fromJSON({});
341
+ const project = await loadProjectInMemory({
342
+ blob: await newProject(),
343
+ providePlugins: [mockPlugin],
344
+ });
345
+ await saveProjectToDirectory({
346
+ path: "/foo/project.inlang",
347
+ fs: volume.promises as any,
348
+ project,
349
+ });
350
+ expect(exportFilesSpy).toHaveBeenCalled();
351
+ expect(saveMessagesSpy).not.toHaveBeenCalled();
352
+ });
353
+
354
+ test("uses saveMessages when exportFiles is not defined", async () => {
355
+ const saveMessagesSpy = vi.fn().mockResolvedValue([]);
356
+ const mockPlugin: InlangPlugin = {
357
+ key: "mock",
358
+ saveMessages: saveMessagesSpy,
359
+ };
360
+ const volume = Volume.fromJSON({});
361
+ const project = await loadProjectInMemory({
362
+ blob: await newProject(),
363
+ providePlugins: [mockPlugin],
364
+ });
365
+ await saveProjectToDirectory({
366
+ path: "/foo/project.inlang",
367
+ fs: volume.promises as any,
368
+ project,
369
+ });
370
+ expect(saveMessagesSpy).toHaveBeenCalled();
371
+ });
@@ -48,19 +48,6 @@ export async function saveProjectToDirectory(args: {
48
48
  const settings = await args.project.settings.get();
49
49
 
50
50
  for (const plugin of plugins) {
51
- // old legacy remove with v3
52
- if (plugin.saveMessages) {
53
- // in-efficient re-qeuery but it's a legacy function that will be removed.
54
- // the effort of adjusting the code to not re-query is not worth it.
55
- const bundlesNested = await selectBundleNested(args.project.db).execute();
56
- await plugin.saveMessages({
57
- messages: bundlesNested.map((b) => toMessageV1(b)),
58
- // @ts-expect-error - legacy
59
- nodeishFs: withAbsolutePaths(args.fs, args.path),
60
- settings,
61
- });
62
- }
63
-
64
51
  if (plugin.exportFiles) {
65
52
  const bundles = await args.project.db
66
53
  .selectFrom("bundle")
@@ -81,7 +68,10 @@ export async function saveProjectToDirectory(args: {
81
68
  settings,
82
69
  });
83
70
  for (const file of files) {
84
- const p = absolutePathFromProject(args.path, file.name);
71
+ const pathPattern = settings[plugin.key]?.pathPattern;
72
+ const p = pathPattern
73
+ ? pathPattern.replace(/\{(languageTag|locale)\}/g, file.locale)
74
+ : absolutePathFromProject(args.path, file.name);
85
75
  const dirname = path.dirname(p);
86
76
  if ((await args.fs.stat(dirname)).isDirectory() === false) {
87
77
  await args.fs.mkdir(dirname, { recursive: true });
@@ -106,5 +96,17 @@ export async function saveProjectToDirectory(args: {
106
96
  }
107
97
  }
108
98
  }
99
+ // old legacy remove with v3
100
+ else if (plugin.saveMessages) {
101
+ // in-efficient re-qeuery but it's a legacy function that will be removed.
102
+ // the effort of adjusting the code to not re-query is not worth it.
103
+ const bundlesNested = await selectBundleNested(args.project.db).execute();
104
+ await plugin.saveMessages({
105
+ messages: bundlesNested.map((b) => toMessageV1(b)),
106
+ // @ts-expect-error - legacy
107
+ nodeishFs: withAbsolutePaths(args.fs, args.path),
108
+ settings,
109
+ });
110
+ }
109
111
  }
110
112
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  import type { ProjectSettings } from "../../json-schema/settings.js";
4
4
  import { ENV_VARIABLES } from "../env-variables/index.js";
5
- import { captureError } from "../error-reporting/index.js";
6
5
 
7
6
  /**
8
7
  * List of telemetry events for typesafety.
@@ -54,8 +53,8 @@ export const capture = async (
54
53
  // we need at least one property to make a project visible in the dashboar
55
54
  properties: { name: args.projectId },
56
55
  });
57
- } catch (e) {
58
- captureError(e);
56
+ } catch {
57
+ // do nothing
59
58
  }
60
59
  };
61
60
 
@@ -93,7 +92,7 @@ const identifyProject = async (args: {
93
92
  },
94
93
  }),
95
94
  });
96
- } catch (e) {
97
- captureError(e);
95
+ } catch {
96
+ // do nothing
98
97
  }
99
98
  };
@@ -1,14 +0,0 @@
1
- import { Kysely } from "kysely";
2
- import { type SqliteDatabase } from "sqlite-wasm-kysely";
3
- import type { Lix } from "@lix-js/sdk";
4
- import type { InlangDatabaseSchema } from "../database/schema.js";
5
- /**
6
- * Saves updates of the database (file) to lix.
7
- */
8
- export declare function initHandleSaveToLixOnChange(args: {
9
- sqlite: SqliteDatabase;
10
- db: Kysely<InlangDatabaseSchema>;
11
- lix: Lix;
12
- pendingPromises: Promise<unknown>[];
13
- }): Promise<void>;
14
- //# sourceMappingURL=initHandleSaveToLixOnChange.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initHandleSaveToLixOnChange.d.ts","sourceRoot":"/","sources":["project/initHandleSaveToLixOnChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAO,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;GAEG;AACH,wBAAsB,2BAA2B,CAAC,IAAI,EAAE;IACvD,MAAM,EAAE,cAAc,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACjC,GAAG,EAAE,GAAG,CAAC;IACT,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;CACpC,iBA+EA"}
@@ -1,87 +0,0 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1a4c93a4-17e3-5a38-bc7d-2850d39d1528")}catch(e){}}();
3
- import { Kysely, sql } from "kysely";
4
- import { contentFromDatabase } from "sqlite-wasm-kysely";
5
- /**
6
- * Saves updates of the database (file) to lix.
7
- */
8
- export async function initHandleSaveToLixOnChange(args) {
9
- args.sqlite.createFunction({
10
- name: "save_db_file_to_lix",
11
- arity: 0,
12
- // @ts-expect-error - dynamic function
13
- xFunc: () => {
14
- // TODO handle in cancellable queue. only the last entry
15
- // in the queue needs to be pushed to the file table
16
- // because all previous entries are overwritten anyways
17
- args.pendingPromises.push((async () => {
18
- try {
19
- // We have to await the database operations to be finished and the database to eb in a consistent state, otherwise contentFromDatabase will crash! 100 ms is too short for current test cases, but we need a proper solution for this
20
- await new Promise((resolve) => setTimeout(resolve, 400));
21
- const data = contentFromDatabase(args.sqlite);
22
- await args.lix.db
23
- .updateTable("file")
24
- .set("data", data)
25
- .where("path", "=", "/db.sqlite")
26
- .execute();
27
- }
28
- catch {
29
- // database has likely been closed.
30
- // TODO needs better handling
31
- }
32
- })());
33
- return;
34
- },
35
- });
36
- // better way to write to lix on updates?
37
- await sql `
38
- CREATE TEMP TRIGGER bundle_insert AFTER INSERT ON bundle
39
- BEGIN
40
- SELECT save_db_file_to_lix();
41
- END;
42
-
43
- CREATE TEMP TRIGGER bundle_update AFTER UPDATE ON bundle
44
- BEGIN
45
- SELECT save_db_file_to_lix();
46
- END;
47
-
48
- CREATE TEMP TRIGGER bundle_delete AFTER DELETE ON bundle
49
- BEGIN
50
- SELECT save_db_file_to_lix();
51
- END;
52
-
53
- CREATE TEMP TRIGGER message_insert AFTER INSERT ON message
54
- BEGIN
55
- SELECT save_db_file_to_lix();
56
- END;
57
-
58
- CREATE TEMP TRIGGER message_update AFTER UPDATE ON message
59
- BEGIN
60
- SELECT save_db_file_to_lix();
61
- END;
62
-
63
- CREATE TEMP TRIGGER message_delete AFTER DELETE ON message
64
- BEGIN
65
- SELECT save_db_file_to_lix();
66
- END;
67
-
68
- CREATE TEMP TRIGGER variant_insert AFTER INSERT ON variant
69
- BEGIN
70
- SELECT save_db_file_to_lix();
71
- END;
72
-
73
- CREATE TEMP TRIGGER variant_update AFTER UPDATE ON variant
74
- BEGIN
75
- SELECT save_db_file_to_lix();
76
- END;
77
-
78
- CREATE TEMP TRIGGER variant_delete AFTER DELETE ON variant
79
- BEGIN
80
- SELECT save_db_file_to_lix();
81
- END;
82
-
83
-
84
- `.execute(args.db);
85
- }
86
- //# sourceMappingURL=initHandleSaveToLixOnChange.js.map
87
- //# debugId=1a4c93a4-17e3-5a38-bc7d-2850d39d1528
@@ -1 +0,0 @@
1
- {"version":3,"file":"initHandleSaveToLixOnChange.js","sources":["project/initHandleSaveToLixOnChange.ts"],"sourceRoot":"/","sourcesContent":["import { Kysely, sql } from \"kysely\";\nimport { contentFromDatabase, type SqliteDatabase } from \"sqlite-wasm-kysely\";\nimport type { Lix } from \"@lix-js/sdk\";\nimport type { InlangDatabaseSchema } from \"../database/schema.js\";\n\n/**\n * Saves updates of the database (file) to lix.\n */\nexport async function initHandleSaveToLixOnChange(args: {\n\tsqlite: SqliteDatabase;\n\tdb: Kysely<InlangDatabaseSchema>;\n\tlix: Lix;\n\tpendingPromises: Promise<unknown>[];\n}) {\n\targs.sqlite.createFunction({\n\t\tname: \"save_db_file_to_lix\",\n\t\tarity: 0,\n\t\t// @ts-expect-error - dynamic function\n\t\txFunc: () => {\n\t\t\t// TODO handle in cancellable queue. only the last entry\n\t\t\t// in the queue needs to be pushed to the file table\n\t\t\t// because all previous entries are overwritten anyways\n\t\t\targs.pendingPromises.push(\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// We have to await the database operations to be finished and the database to eb in a consistent state, otherwise contentFromDatabase will crash! 100 ms is too short for current test cases, but we need a proper solution for this\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 400));\n\t\t\t\t\t\tconst data = contentFromDatabase(args.sqlite);\n\t\t\t\t\t\tawait args.lix.db\n\t\t\t\t\t\t\t.updateTable(\"file\")\n\t\t\t\t\t\t\t.set(\"data\", data)\n\t\t\t\t\t\t\t.where(\"path\", \"=\", \"/db.sqlite\")\n\t\t\t\t\t\t\t.execute();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// database has likely been closed.\n\t\t\t\t\t\t// TODO needs better handling\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t);\n\t\t\treturn;\n\t\t},\n\t});\n\n\t// better way to write to lix on updates?\n\tawait sql`\n\tCREATE TEMP TRIGGER bundle_insert AFTER INSERT ON bundle\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER bundle_update AFTER UPDATE ON bundle\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER bundle_delete AFTER DELETE ON bundle\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\t\tCREATE TEMP TRIGGER message_insert AFTER INSERT ON message\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER message_update AFTER UPDATE ON message\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER message_delete AFTER DELETE ON message\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER variant_insert AFTER INSERT ON variant\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER variant_update AFTER UPDATE ON variant\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\tCREATE TEMP TRIGGER variant_delete AFTER DELETE ON variant\n\tBEGIN\n\t SELECT save_db_file_to_lix();\n\tEND;\n\n\n\t`.execute(args.db);\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,oBAAoB,CAAC;AAI9E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAKjD;IACA,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QAC1B,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,CAAC;QACR,sCAAsC;QACtC,KAAK,EAAE,GAAG,EAAE;YACX,wDAAwD;YACxD,oDAAoD;YACpD,uDAAuD;YACvD,IAAI,CAAC,eAAe,CAAC,IAAI,CACxB,CAAC,KAAK,IAAI,EAAE;gBACX,IAAI,CAAC;oBACJ,qOAAqO;oBACrO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;oBACzD,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC9C,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE;yBACf,WAAW,CAAC,MAAM,CAAC;yBACnB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC;yBACjB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC;yBAChC,OAAO,EAAE,CAAC;gBACb,CAAC;gBAAC,MAAM,CAAC;oBACR,mCAAmC;oBACnC,6BAA6B;gBAC9B,CAAC;YACF,CAAC,CAAC,EAAE,CACJ,CAAC;YACF,OAAO;QACR,CAAC;KACD,CAAC,CAAC;IAEH,yCAAyC;IACzC,MAAM,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+CR,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC","debug_id":"1a4c93a4-17e3-5a38-bc7d-2850d39d1528"}
@@ -1,15 +0,0 @@
1
- export declare function initErrorReporting(args: {
2
- projectId: string;
3
- }): void;
4
- /**
5
- * Capture an error.
6
- *
7
- * @example
8
- * try {
9
- * throw new Error("Something went wrong");
10
- * } catch (error) {
11
- * captureError(error);
12
- * }
13
- */
14
- export declare function captureError(error: Error | any): string;
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["services/error-reporting/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,QAU7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,UAE9C"}
@@ -1,30 +0,0 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6bcf1424-1b5e-5ac6-bdaf-bac4dd7a888b")}catch(e){}}();
3
- import { init, setUser, captureException } from "@sentry/browser";
4
- import { ENV_VARIABLES } from "../env-variables/index.js";
5
- export function initErrorReporting(args) {
6
- if (ENV_VARIABLES.PUBLIC_INLANG_SDK_SENTRY_DSN) {
7
- // in order to receive alerts like "if more than 100 "users" are effected, notify the team"
8
- // the user id is set to the project id
9
- setUser({ id: args.projectId });
10
- init({
11
- dsn: ENV_VARIABLES.PUBLIC_INLANG_SDK_SENTRY_DSN,
12
- release: ENV_VARIABLES.SDK_VERSION,
13
- });
14
- }
15
- }
16
- /**
17
- * Capture an error.
18
- *
19
- * @example
20
- * try {
21
- * throw new Error("Something went wrong");
22
- * } catch (error) {
23
- * captureError(error);
24
- * }
25
- */
26
- export function captureError(error) {
27
- return captureException(error);
28
- }
29
- //# sourceMappingURL=index.js.map
30
- //# debugId=6bcf1424-1b5e-5ac6-bdaf-bac4dd7a888b
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["services/error-reporting/index.ts"],"sourceRoot":"/","sourcesContent":["import { init, setUser, captureException } from \"@sentry/browser\";\nimport { ENV_VARIABLES } from \"../env-variables/index.js\";\n\nexport function initErrorReporting(args: { projectId: string }) {\n\tif (ENV_VARIABLES.PUBLIC_INLANG_SDK_SENTRY_DSN) {\n\t\t// in order to receive alerts like \"if more than 100 \"users\" are effected, notify the team\"\n\t\t// the user id is set to the project id\n\t\tsetUser({ id: args.projectId });\n\t\tinit({\n\t\t\tdsn: ENV_VARIABLES.PUBLIC_INLANG_SDK_SENTRY_DSN,\n\t\t\trelease: ENV_VARIABLES.SDK_VERSION,\n\t\t});\n\t}\n}\n\n/**\n * Capture an error.\n *\n * @example\n * try {\n * throw new Error(\"Something went wrong\");\n * } catch (error) {\n * captureError(error);\n * }\n */\nexport function captureError(error: Error | any) {\n\treturn captureException(error);\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,UAAU,kBAAkB,CAAC,IAA2B;IAC7D,IAAI,aAAa,CAAC,4BAA4B,EAAE,CAAC;QAChD,2FAA2F;QAC3F,uCAAuC;QACvC,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC;YACJ,GAAG,EAAE,aAAa,CAAC,4BAA4B;YAC/C,OAAO,EAAE,aAAa,CAAC,WAAW;SAClC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC9C,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC","debug_id":"6bcf1424-1b5e-5ac6-bdaf-bac4dd7a888b"}