@upstart.gg/sdk 0.0.104 → 0.0.106
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/shared/ajv.d.ts +2 -0
- package/dist/shared/ajv.d.ts.map +1 -1
- package/dist/shared/ajv.js +1 -1
- package/dist/shared/attributes.js +1 -1
- package/dist/shared/brick-manifest.js +1 -1
- package/dist/shared/bricks/manifests/accordion.manifest.js +1 -1
- package/dist/shared/bricks/manifests/all-manifests.js +1 -1
- package/dist/shared/bricks/manifests/button.manifest.js +1 -1
- package/dist/shared/bricks/manifests/card.manifest.js +1 -1
- package/dist/shared/bricks/manifests/carousel.manifest.js +1 -1
- package/dist/shared/bricks/manifests/container.manifest.js +1 -1
- package/dist/shared/bricks/manifests/divider.manifest.js +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.d.ts +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.js +1 -1
- package/dist/shared/bricks/manifests/form.manifest.js +1 -1
- package/dist/shared/bricks/manifests/hero.manifest.js +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.js +1 -1
- package/dist/shared/bricks/manifests/image.manifest.js +1 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.js +1 -1
- package/dist/shared/bricks/manifests/map.manifest.js +1 -1
- package/dist/shared/bricks/manifests/navbar.manifest.js +1 -1
- package/dist/shared/bricks/manifests/sidebar.manifest.js +1 -1
- package/dist/shared/bricks/manifests/social-links.manifest.js +1 -1
- package/dist/shared/bricks/manifests/testimonials.manifest.js +1 -1
- package/dist/shared/bricks/manifests/text.manifest.js +1 -1
- package/dist/shared/bricks/manifests/timeline.manifest.js +1 -1
- package/dist/shared/bricks/manifests/video.manifest.js +1 -1
- package/dist/shared/bricks/props/border.d.ts.map +1 -1
- package/dist/shared/bricks/props/border.js +1 -1
- package/dist/shared/bricks/props/container.js +1 -1
- package/dist/shared/bricks/props/effects.js +1 -1
- package/dist/shared/bricks.d.ts.map +1 -1
- package/dist/shared/bricks.js +1 -1
- package/dist/shared/{chunk-TCZBR3ZU.js → chunk-2DI5SIVV.js} +1 -1
- package/dist/shared/{chunk-O22VV7YR.js → chunk-33FU4KGU.js} +1 -1
- package/dist/shared/{chunk-WCNVFVDK.js → chunk-3ZGRY444.js} +1 -1
- package/dist/shared/{chunk-CUCUHPQ7.js → chunk-6OKXZL6R.js} +1 -1
- package/dist/shared/chunk-7E67XSKP.js +3 -0
- package/dist/shared/{chunk-LJQXN32B.js → chunk-AMGHA7QH.js} +1 -1
- package/dist/shared/{chunk-QALNFBY7.js → chunk-DC5DWF7B.js} +1 -1
- package/dist/shared/{chunk-I43NIQ2K.js → chunk-DY2YCYZ6.js} +1 -1
- package/dist/shared/{chunk-CEXHD4BO.js → chunk-E4UAVLKC.js} +2 -2
- package/dist/shared/{chunk-ZFTWLZ3G.js → chunk-EHH677K5.js} +1 -1
- package/dist/shared/{chunk-POYVTV5F.js → chunk-FD3KX2U7.js} +1 -1
- package/dist/shared/chunk-G3JO5DM5.js +3 -0
- package/dist/shared/{chunk-I5S2MPPR.js → chunk-H7OYUKBW.js} +1 -1
- package/dist/shared/{chunk-ATVHWZSA.js → chunk-HBM4DPIW.js} +1 -1
- package/dist/shared/chunk-HIBTEX2T.js +3 -0
- package/dist/shared/{chunk-E2EBTWJI.js → chunk-I3HSLGFA.js} +1 -1
- package/dist/shared/{chunk-UISES3HA.js → chunk-IXJX7EQ3.js} +1 -1
- package/dist/shared/{chunk-5IEGQ7YT.js → chunk-JAAPJQNK.js} +1 -1
- package/dist/shared/{chunk-UK6H3FDX.js → chunk-JDBVMPSI.js} +1 -1
- package/dist/shared/{chunk-F6MLW6DO.js → chunk-JH3NRO6M.js} +1 -1
- package/dist/shared/{chunk-ZNVRYEO7.js → chunk-L3TKLJKK.js} +1 -1
- package/dist/shared/{chunk-TEPFFY32.js → chunk-LOFXGDAK.js} +1 -1
- package/dist/shared/chunk-O3FJP65T.js +3 -0
- package/dist/shared/{chunk-7L3UOEMR.js → chunk-PX7QSNLO.js} +1 -1
- package/dist/shared/{chunk-22KRCQK5.js → chunk-U76JDFWJ.js} +1 -1
- package/dist/shared/{chunk-CW5FWW5W.js → chunk-UYZP24VV.js} +1 -1
- package/dist/shared/chunk-X42WBJTN.js +3 -0
- package/dist/shared/{chunk-OQIFFJ7I.js → chunk-XB3X4P3I.js} +1 -1
- package/dist/shared/chunk-XDCGA4WT.js +3 -0
- package/dist/shared/chunk-YGHBFXR6.js +3 -0
- package/dist/shared/{chunk-WEQRYCPD.js → chunk-ZWYLKIBI.js} +1 -1
- package/dist/shared/datasources/external/rss/fetcher.d.ts +1 -1
- package/dist/shared/datasources/external/rss/fetcher.d.ts.map +1 -1
- package/dist/shared/images.js +1 -1
- package/dist/shared/page.js +1 -1
- package/dist/shared/responsive.js +1 -1
- package/dist/shared/site.js +1 -1
- package/dist/shared/sitemap.js +1 -1
- package/dist/shared/theme.js +1 -1
- package/dist/shared/utils/schema.d.ts +6 -8
- package/dist/shared/utils/schema.d.ts.map +1 -1
- package/dist/shared/utils/schema.js +1 -1
- package/package.json +5 -9
- package/dist/shared/chunk-F63ANNAK.js +0 -3
- package/dist/shared/chunk-GPKRRX3D.js +0 -3
- package/dist/shared/chunk-HQQYIKTE.js +0 -3
- package/dist/shared/chunk-JFDOR3UH.js +0 -3
- package/dist/shared/chunk-OD2PRCLH.js +0 -3
- package/dist/shared/chunk-PK6UAFPW.js +0 -3
- package/dist/shared/chunk-VDHLON5R.js +0 -3
- package/src/node/cli/api.ts +0 -101
- package/src/node/cli/commands/cmd-build.ts +0 -64
- package/src/node/cli/commands/login/cmd-login.ts +0 -111
- package/src/node/cli/commands/logout/cmd-logout.ts +0 -11
- package/src/node/cli/commands/publish/cmd-publish.ts +0 -135
- package/src/node/cli/commands/publish/parse-gitignore.ts +0 -278
- package/src/node/cli/commands/publish/uploader.ts +0 -333
- package/src/node/cli/constants.ts +0 -14
- package/src/node/cli/is-logged-in.ts +0 -28
- package/src/node/cli/program.ts +0 -77
- package/src/node/cli/store.ts +0 -64
- package/src/node/cli/tests/api.test.ts +0 -161
- package/src/node/cli/types.ts +0 -34
- package/src/node/cli/utils.ts +0 -20
- package/src/node/shared/config.ts +0 -69
- package/src/node/shared/logger.ts +0 -44
- package/src/shared/ajv.ts +0 -103
- package/src/shared/analytics/init.ts +0 -14
- package/src/shared/analytics/track.ts +0 -21
- package/src/shared/analytics/types.ts +0 -13
- package/src/shared/attributes.ts +0 -211
- package/src/shared/brick-manifest.ts +0 -110
- package/src/shared/bricks/manifests/accordion.manifest.ts +0 -179
- package/src/shared/bricks/manifests/all-manifests.ts +0 -92
- package/src/shared/bricks/manifests/button.manifest.ts +0 -145
- package/src/shared/bricks/manifests/card.manifest.ts +0 -269
- package/src/shared/bricks/manifests/carousel.manifest.ts +0 -106
- package/src/shared/bricks/manifests/container.manifest.ts +0 -357
- package/src/shared/bricks/manifests/divider.manifest.ts +0 -121
- package/src/shared/bricks/manifests/footer.manifest.ts +0 -487
- package/src/shared/bricks/manifests/form.manifest.ts +0 -112
- package/src/shared/bricks/manifests/hero.manifest.ts +0 -132
- package/src/shared/bricks/manifests/icon.manifest.ts +0 -130
- package/src/shared/bricks/manifests/image.manifest.ts +0 -203
- package/src/shared/bricks/manifests/images-gallery.manifest.ts +0 -227
- package/src/shared/bricks/manifests/map.manifest.ts +0 -75
- package/src/shared/bricks/manifests/navbar.manifest.ts +0 -344
- package/src/shared/bricks/manifests/sidebar.manifest.ts +0 -90
- package/src/shared/bricks/manifests/social-links.manifest.ts +0 -370
- package/src/shared/bricks/manifests/testimonials.manifest.ts +0 -397
- package/src/shared/bricks/manifests/tests/header.manifest.test.ts +0 -10
- package/src/shared/bricks/manifests/text.manifest.ts +0 -164
- package/src/shared/bricks/manifests/timeline.manifest.ts +0 -456
- package/src/shared/bricks/manifests/video.manifest.ts +0 -59
- package/src/shared/bricks/props/_style-presets.ts +0 -352
- package/src/shared/bricks/props/align.ts +0 -59
- package/src/shared/bricks/props/background.ts +0 -118
- package/src/shared/bricks/props/boolean.ts +0 -11
- package/src/shared/bricks/props/border.ts +0 -84
- package/src/shared/bricks/props/color.ts +0 -24
- package/src/shared/bricks/props/common.ts +0 -37
- package/src/shared/bricks/props/container.ts +0 -356
- package/src/shared/bricks/props/css-length.ts +0 -25
- package/src/shared/bricks/props/datasource.ts +0 -60
- package/src/shared/bricks/props/date.ts +0 -24
- package/src/shared/bricks/props/effects.ts +0 -123
- package/src/shared/bricks/props/enum.ts +0 -42
- package/src/shared/bricks/props/file.ts +0 -12
- package/src/shared/bricks/props/geolocation.ts +0 -30
- package/src/shared/bricks/props/helpers.ts +0 -101
- package/src/shared/bricks/props/image.ts +0 -90
- package/src/shared/bricks/props/number.ts +0 -16
- package/src/shared/bricks/props/padding.ts +0 -21
- package/src/shared/bricks/props/position.ts +0 -27
- package/src/shared/bricks/props/preset.ts +0 -136
- package/src/shared/bricks/props/string.ts +0 -56
- package/src/shared/bricks/props/tests/align.test.ts +0 -37
- package/src/shared/bricks/props/tests/background.test.ts +0 -102
- package/src/shared/bricks/props/tests/border.test.ts +0 -38
- package/src/shared/bricks/props/tests/effects.test.ts +0 -37
- package/src/shared/bricks/props/tests/helpers.test.ts +0 -133
- package/src/shared/bricks/props/tests/image.test.ts +0 -71
- package/src/shared/bricks/props/tests/padding.ts +0 -12
- package/src/shared/bricks/props/tests/string.test.ts +0 -79
- package/src/shared/bricks/props/text.ts +0 -66
- package/src/shared/bricks/props/types.ts +0 -57
- package/src/shared/bricks.ts +0 -232
- package/src/shared/context.ts +0 -39
- package/src/shared/datarecords/external/airtable/handler.ts +0 -21
- package/src/shared/datarecords/external/airtable/options.ts +0 -22
- package/src/shared/datarecords/external/generic-webhook/handler.ts +0 -10
- package/src/shared/datarecords/external/generic-webhook/options.ts +0 -13
- package/src/shared/datarecords/external/google/oauth/config.ts +0 -30
- package/src/shared/datarecords/external/google/sheets/handler.ts +0 -26
- package/src/shared/datarecords/external/google/sheets/options.ts +0 -9
- package/src/shared/datarecords/types.ts +0 -120
- package/src/shared/datarecords.ts +0 -5
- package/src/shared/datasources/README.md +0 -3
- package/src/shared/datasources/external/facebook/posts/fetcher.ts +0 -52
- package/src/shared/datasources/external/facebook/posts/sample.ts +0 -35
- package/src/shared/datasources/external/facebook/posts/schema.ts +0 -33
- package/src/shared/datasources/external/facebook/posts/tests/fetcher.test.ts +0 -73
- package/src/shared/datasources/external/http-json/fetcher.ts +0 -28
- package/src/shared/datasources/external/http-json/options.ts +0 -12
- package/src/shared/datasources/external/http-json/schema.ts +0 -6
- package/src/shared/datasources/external/http-json/tests/fetcher.test.ts +0 -70
- package/src/shared/datasources/external/instagram/feed/fetcher.ts +0 -33
- package/src/shared/datasources/external/instagram/feed/sample.ts +0 -22
- package/src/shared/datasources/external/instagram/feed/schema.ts +0 -23
- package/src/shared/datasources/external/instagram/feed/tests/fetcher.test.ts +0 -64
- package/src/shared/datasources/external/mastodon/account/fetcher.ts +0 -24
- package/src/shared/datasources/external/mastodon/account/sample.ts +0 -33
- package/src/shared/datasources/external/mastodon/account/schema.ts +0 -45
- package/src/shared/datasources/external/mastodon/account/tests/fetcher.test.ts +0 -47
- package/src/shared/datasources/external/mastodon/options.ts +0 -11
- package/src/shared/datasources/external/mastodon/status/fetcher.ts +0 -35
- package/src/shared/datasources/external/mastodon/status/sample.array.ts +0 -59
- package/src/shared/datasources/external/mastodon/status/sample.single.ts +0 -55
- package/src/shared/datasources/external/mastodon/status/schema.ts +0 -130
- package/src/shared/datasources/external/mastodon/status/tests/fetcher.test.ts +0 -74
- package/src/shared/datasources/external/meta/oauth/config.ts +0 -16
- package/src/shared/datasources/external/meta/options.ts +0 -11
- package/src/shared/datasources/external/rss/fetcher.ts +0 -29
- package/src/shared/datasources/external/rss/options.ts +0 -11
- package/src/shared/datasources/external/rss/sample.ts +0 -22
- package/src/shared/datasources/external/rss/schema.ts +0 -42
- package/src/shared/datasources/external/threads/media/fetcher.ts +0 -53
- package/src/shared/datasources/external/threads/media/sample.ts +0 -44
- package/src/shared/datasources/external/threads/media/schema.ts +0 -37
- package/src/shared/datasources/external/tiktok/oauth/config.ts +0 -17
- package/src/shared/datasources/external/tiktok/video/fetcher.ts +0 -39
- package/src/shared/datasources/external/tiktok/video/options.ts +0 -12
- package/src/shared/datasources/external/tiktok/video/sample.ts +0 -26
- package/src/shared/datasources/external/tiktok/video/schema.ts +0 -27
- package/src/shared/datasources/external/youtube/list/fetcher.ts +0 -37
- package/src/shared/datasources/external/youtube/list/options.ts +0 -15
- package/src/shared/datasources/external/youtube/list/sample.ts +0 -33
- package/src/shared/datasources/external/youtube/list/schema.ts +0 -38
- package/src/shared/datasources/external/youtube/oauth/config.ts +0 -15
- package/src/shared/datasources/fetcher.ts +0 -17
- package/src/shared/datasources/internal/blog/schema.ts +0 -69
- package/src/shared/datasources/internal/changelog/schema.ts +0 -48
- package/src/shared/datasources/internal/contact-info/schema.ts +0 -20
- package/src/shared/datasources/internal/cv/schema.ts +0 -217
- package/src/shared/datasources/internal/faq/schema.ts +0 -27
- package/src/shared/datasources/internal/job-board/schema.ts +0 -228
- package/src/shared/datasources/internal/links/schema.ts +0 -15
- package/src/shared/datasources/internal/recipes/schema.ts +0 -42
- package/src/shared/datasources/internal/restaurant/schema.ts +0 -225
- package/src/shared/datasources/provider-options.ts +0 -7
- package/src/shared/datasources/samples.ts +0 -26
- package/src/shared/datasources/schemas.ts +0 -45
- package/src/shared/datasources/types.ts +0 -276
- package/src/shared/datasources/utils.ts +0 -16
- package/src/shared/datasources.ts +0 -42
- package/src/shared/env.ts +0 -23
- package/src/shared/errors.ts +0 -1
- package/src/shared/images.ts +0 -44
- package/src/shared/index.ts +0 -3
- package/src/shared/layout-constants.ts +0 -25
- package/src/shared/manifest.ts +0 -50
- package/src/shared/oauth.ts +0 -16
- package/src/shared/page.ts +0 -61
- package/src/shared/prompt.ts +0 -9
- package/src/shared/responsive.ts +0 -5
- package/src/shared/site.ts +0 -97
- package/src/shared/sitemap.ts +0 -66
- package/src/shared/social-icons.ts +0 -307
- package/src/shared/tests/attributes.test.ts +0 -37
- package/src/shared/theme.ts +0 -245
- package/src/shared/themes/README.md +0 -34
- package/src/shared/themes/color-system.ts +0 -127
- package/src/shared/utils/canvas-data-uri.ts +0 -2
- package/src/shared/utils/invariant.ts +0 -25
- package/src/shared/utils/json-date.ts +0 -8
- package/src/shared/utils/merge.ts +0 -12
- package/src/shared/utils/object-hash.ts +0 -7
- package/src/shared/utils/schema.ts +0 -35
- package/src/shared/utils/try-catch.ts +0 -12
- package/src/shared/utils/typed-ref.ts +0 -41
package/src/node/cli/program.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { program, type Command, type OptionValues } from "commander";
|
|
3
|
-
import type { BuildOptions, CommonOptions } from "./types";
|
|
4
|
-
import { publish } from "./commands/publish/cmd-publish";
|
|
5
|
-
import { login } from "./commands/login/cmd-login";
|
|
6
|
-
import { buildTemplate } from "./commands/cmd-build";
|
|
7
|
-
import { createLogger, type Logger } from "../shared/logger";
|
|
8
|
-
import { logout } from "./commands/logout/cmd-logout";
|
|
9
|
-
|
|
10
|
-
let logger: Logger;
|
|
11
|
-
|
|
12
|
-
program
|
|
13
|
-
.name("enpage")
|
|
14
|
-
.option("-l, --logLevel <level>", `[string] info | warn | error | silent | debug`)
|
|
15
|
-
.option("--clearScreen", `[boolean] allow/disable clear screen when logging`)
|
|
16
|
-
.option("--dry-run", `[boolean] run command without making changes`)
|
|
17
|
-
.hook("preAction", (thisCommand) => {
|
|
18
|
-
logger = createLogger(
|
|
19
|
-
thisCommand.optsWithGlobals().logLevel,
|
|
20
|
-
thisCommand.optsWithGlobals().clearScreen,
|
|
21
|
-
true,
|
|
22
|
-
);
|
|
23
|
-
// for now, disable the form-data warning until they fix it
|
|
24
|
-
process.removeAllListeners("warning");
|
|
25
|
-
process.on("warning", (warning) => {
|
|
26
|
-
if (warning.name === "DeprecationWarning" && warning.message.includes("util.isArray")) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
logger.warnOnce(`Warning: ${warning.name} - ${warning.message}`);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
program
|
|
34
|
-
.command("build")
|
|
35
|
-
.description("Build template")
|
|
36
|
-
.option(
|
|
37
|
-
"--ssr [type]",
|
|
38
|
-
`Enable server side rendering.
|
|
39
|
-
Pass --ssr to generate a SSR-enabled build.
|
|
40
|
-
Pass --ssr=local to generate a SSR-enabled build that can be tested locally.`,
|
|
41
|
-
Boolean,
|
|
42
|
-
false,
|
|
43
|
-
)
|
|
44
|
-
.option("--no-clean", `Don't clean directory before buidling`)
|
|
45
|
-
.action(function (this: Command) {
|
|
46
|
-
buildTemplate(getArgsOptionsObject<BuildOptions>(this));
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
program
|
|
50
|
-
.command("publish")
|
|
51
|
-
.description("Publish a template to Enpage")
|
|
52
|
-
.argument("[directory]", "Directory to publish")
|
|
53
|
-
.option("--no-check", `Don't check for required files`)
|
|
54
|
-
|
|
55
|
-
.action(function (this: Command) {
|
|
56
|
-
publish(getArgsOptionsObject(this));
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
program
|
|
60
|
-
.command("login")
|
|
61
|
-
.description("Login to Enpage")
|
|
62
|
-
.action(function (this: Command) {
|
|
63
|
-
login(getArgsOptionsObject(this));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
program
|
|
67
|
-
.command("logout")
|
|
68
|
-
.description("Logout from Enpage")
|
|
69
|
-
.action(function (this: Command) {
|
|
70
|
-
logout(getArgsOptionsObject(this));
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
program.parse();
|
|
74
|
-
|
|
75
|
-
function getArgsOptionsObject<O extends OptionValues>(cmd: Command) {
|
|
76
|
-
return { options: cmd.optsWithGlobals<CommonOptions & O>(), args: cmd.args, logger };
|
|
77
|
-
}
|
package/src/node/cli/store.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { CredentialsStore } from "./types";
|
|
2
|
-
import { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from "./constants";
|
|
3
|
-
import Conf from "conf";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import crypto from "node:crypto";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { getPackageManager } from "./utils";
|
|
9
|
-
import chalk from "chalk";
|
|
10
|
-
|
|
11
|
-
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
12
|
-
const key = getKey();
|
|
13
|
-
const accessStore = new Conf<CredentialsStore>({
|
|
14
|
-
projectName: CLI_PROJECT_NAME,
|
|
15
|
-
encryptionKey: key,
|
|
16
|
-
clearInvalidConfig: true,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get access token or throw error if not found
|
|
21
|
-
*/
|
|
22
|
-
export function getTokenOrThrow() {
|
|
23
|
-
const token = accessStore.get("access_token");
|
|
24
|
-
if (!token) {
|
|
25
|
-
const pkgCmd = getPackageManager();
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return token;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function findNearestNodeModules(): string | null {
|
|
34
|
-
let currentDir = __dirname;
|
|
35
|
-
while (currentDir !== path.parse(currentDir).root) {
|
|
36
|
-
const nodeModulesPath = path.join(currentDir, "node_modules");
|
|
37
|
-
if (fs.existsSync(nodeModulesPath)) {
|
|
38
|
-
return nodeModulesPath;
|
|
39
|
-
}
|
|
40
|
-
currentDir = path.dirname(currentDir);
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getKey() {
|
|
46
|
-
const nodeModulesPath = findNearestNodeModules();
|
|
47
|
-
if (!nodeModulesPath) {
|
|
48
|
-
throw new Error("Could not find nearest node_modules directory.");
|
|
49
|
-
}
|
|
50
|
-
const tmpSecureStoreDir = path.join(nodeModulesPath, ".enpage-tmp");
|
|
51
|
-
if (!fs.existsSync(tmpSecureStoreDir)) {
|
|
52
|
-
fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });
|
|
53
|
-
}
|
|
54
|
-
const keyPath = path.join(tmpSecureStoreDir, ".enpage-key");
|
|
55
|
-
if (!fs.existsSync(keyPath)) {
|
|
56
|
-
const key = crypto.randomBytes(32).toString("hex");
|
|
57
|
-
fs.writeFileSync(keyPath, key, { mode: 0o600 });
|
|
58
|
-
return key;
|
|
59
|
-
}
|
|
60
|
-
const key = fs.readFileSync(keyPath, "utf8");
|
|
61
|
-
return key;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { accessStore };
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { post, get } from "../api";
|
|
3
|
-
import { accessStore } from "../store";
|
|
4
|
-
|
|
5
|
-
vi.mock("../store", () => ({
|
|
6
|
-
accessStore: {
|
|
7
|
-
get: vi.fn(),
|
|
8
|
-
},
|
|
9
|
-
getToken: vi.fn(),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
vi.mock("../shared/logger", () => ({
|
|
13
|
-
logger: {
|
|
14
|
-
error: vi.fn(),
|
|
15
|
-
},
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
global.fetch = vi.fn();
|
|
19
|
-
|
|
20
|
-
describe("API functions", () => {
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
vi.resetAllMocks();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
vi.restoreAllMocks();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("post", () => {
|
|
30
|
-
it("should make a POST request with correct headers and body", async () => {
|
|
31
|
-
const mockResponse = { data: "test" };
|
|
32
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
33
|
-
ok: true,
|
|
34
|
-
status: 200,
|
|
35
|
-
statusText: "OK",
|
|
36
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
37
|
-
json: () => Promise.resolve(mockResponse),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const result = await post("/test", { key: "value" });
|
|
41
|
-
|
|
42
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
43
|
-
expect.any(URL),
|
|
44
|
-
expect.objectContaining({
|
|
45
|
-
method: "POST",
|
|
46
|
-
headers: expect.objectContaining({
|
|
47
|
-
"Content-Type": "application/json",
|
|
48
|
-
}),
|
|
49
|
-
body: JSON.stringify({ key: "value" }),
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
52
|
-
expect(result).toEqual({
|
|
53
|
-
isSuccess: true,
|
|
54
|
-
isError: false,
|
|
55
|
-
status: 200,
|
|
56
|
-
statusText: "OK",
|
|
57
|
-
data: mockResponse,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should handle URLSearchParams correctly", async () => {
|
|
62
|
-
const mockResponse = { data: "test" };
|
|
63
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
64
|
-
ok: true,
|
|
65
|
-
status: 200,
|
|
66
|
-
statusText: "OK",
|
|
67
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
68
|
-
json: () => Promise.resolve(mockResponse),
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const params = new URLSearchParams({ key: "value" });
|
|
72
|
-
await post("/test", params);
|
|
73
|
-
|
|
74
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
75
|
-
expect.any(URL),
|
|
76
|
-
expect.objectContaining({
|
|
77
|
-
headers: expect.objectContaining({
|
|
78
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
79
|
-
}),
|
|
80
|
-
body: params,
|
|
81
|
-
}),
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should handle error responses", async () => {
|
|
86
|
-
const errorResponse = { error: "Test error" };
|
|
87
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
88
|
-
ok: false,
|
|
89
|
-
status: 400,
|
|
90
|
-
statusText: "Bad Request",
|
|
91
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
92
|
-
json: () => Promise.resolve(errorResponse),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const result = await post("/test", { key: "value" });
|
|
96
|
-
|
|
97
|
-
expect(result).toEqual({
|
|
98
|
-
isSuccess: false,
|
|
99
|
-
isError: true,
|
|
100
|
-
status: 400,
|
|
101
|
-
statusText: "Bad Request",
|
|
102
|
-
data: errorResponse,
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
describe("get", () => {
|
|
108
|
-
it("should make a GET request with correct headers", async () => {
|
|
109
|
-
const mockResponse = { data: "test" };
|
|
110
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
111
|
-
ok: true,
|
|
112
|
-
status: 200,
|
|
113
|
-
statusText: "OK",
|
|
114
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
115
|
-
json: () => Promise.resolve(mockResponse),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
vi.mocked(accessStore.get).mockReturnValue("test-token");
|
|
119
|
-
|
|
120
|
-
const result = await get("/test");
|
|
121
|
-
|
|
122
|
-
expect(global.fetch).toHaveBeenCalledWith(
|
|
123
|
-
expect.any(URL),
|
|
124
|
-
expect.objectContaining({
|
|
125
|
-
method: "GET",
|
|
126
|
-
headers: expect.objectContaining({
|
|
127
|
-
Authorization: "Bearer test-token",
|
|
128
|
-
}),
|
|
129
|
-
}),
|
|
130
|
-
);
|
|
131
|
-
expect(result).toEqual({
|
|
132
|
-
isSuccess: true,
|
|
133
|
-
isError: false,
|
|
134
|
-
status: 200,
|
|
135
|
-
statusText: "OK",
|
|
136
|
-
data: mockResponse,
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("should handle error responses", async () => {
|
|
141
|
-
const errorResponse = { error: "Test error" };
|
|
142
|
-
(global.fetch as any).mockResolvedValueOnce({
|
|
143
|
-
ok: false,
|
|
144
|
-
status: 404,
|
|
145
|
-
statusText: "Not Found",
|
|
146
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
147
|
-
json: () => Promise.resolve(errorResponse),
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const result = await get("/test");
|
|
151
|
-
|
|
152
|
-
expect(result).toEqual({
|
|
153
|
-
isSuccess: false,
|
|
154
|
-
isError: true,
|
|
155
|
-
status: 404,
|
|
156
|
-
statusText: "Not Found",
|
|
157
|
-
data: errorResponse,
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
package/src/node/cli/types.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { OptionValues } from "commander";
|
|
2
|
-
import type { Logger } from "../shared/logger";
|
|
3
|
-
|
|
4
|
-
export type CredentialsStore = {
|
|
5
|
-
access_token: string;
|
|
6
|
-
token_type: string;
|
|
7
|
-
expires_in?: number;
|
|
8
|
-
refresh_token?: string;
|
|
9
|
-
refresh_token_expires_in?: number;
|
|
10
|
-
scope?: string;
|
|
11
|
-
expires_at: number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type CommandArgOpts<Opts extends OptionValues = OptionValues> = {
|
|
15
|
-
args: string[];
|
|
16
|
-
options: CommonOptions & Opts;
|
|
17
|
-
logger: Logger;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type CommonOptions = {
|
|
21
|
-
logLevel?: "info" | "warn" | "error" | "silent";
|
|
22
|
-
clearScreen?: boolean;
|
|
23
|
-
dryRun?: boolean;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type BuildOptions = {
|
|
27
|
-
ssr: boolean | "local";
|
|
28
|
-
clean?: boolean;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type GenericApiError = {
|
|
32
|
-
error: string;
|
|
33
|
-
error_description: string;
|
|
34
|
-
};
|
package/src/node/cli/utils.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function getPackageManager() {
|
|
2
|
-
// Detect package manager
|
|
3
|
-
let packageManager: string | undefined;
|
|
4
|
-
if (process.env.npm_config_user_agent) {
|
|
5
|
-
const pmPart = process.env.npm_config_user_agent.split(" ")[0];
|
|
6
|
-
packageManager = pmPart.slice(0, pmPart.lastIndexOf("/"));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Display message
|
|
10
|
-
if (!packageManager) {
|
|
11
|
-
console.log("Warning: could not detect package manager");
|
|
12
|
-
packageManager = "npm";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return packageManager;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function formatAPIError(error: { error: string; error_description?: string }) {
|
|
19
|
-
return `[${error.error}]${error.error_description ? `: ${error.error_description}` : ""}`;
|
|
20
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import fg from "fast-glob";
|
|
4
|
-
import { type Logger, logger as defaultLogger } from "./logger";
|
|
5
|
-
import { basename, dirname, extname } from "node:path";
|
|
6
|
-
import type { SiteAndPagesConfig } from "~/shared/site";
|
|
7
|
-
|
|
8
|
-
export async function loadConfigFromJsFile(
|
|
9
|
-
configPath: string,
|
|
10
|
-
logger = defaultLogger as Logger,
|
|
11
|
-
): Promise<SiteAndPagesConfig> {
|
|
12
|
-
if (!fs.existsSync(configPath)) {
|
|
13
|
-
logger.error(
|
|
14
|
-
"🔴 No enpage.config.js found!\nYour project must have an enpage.config.js file in the root directory.\n\n",
|
|
15
|
-
);
|
|
16
|
-
process.exit(1);
|
|
17
|
-
}
|
|
18
|
-
const config = (await import(configPath)) as SiteAndPagesConfig;
|
|
19
|
-
|
|
20
|
-
// Parse the readme files fro the same directory as the config file
|
|
21
|
-
const readmePath = dirname(configPath);
|
|
22
|
-
const readme: Record<string, string> = {};
|
|
23
|
-
const readmeFiles = await fg(["README.enpage.md", "README.enpage.*.md"], {
|
|
24
|
-
cwd: readmePath,
|
|
25
|
-
onlyFiles: true,
|
|
26
|
-
absolute: true,
|
|
27
|
-
caseSensitiveMatch: false,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
for (const file of readmeFiles) {
|
|
31
|
-
const base = basename(file, ".md");
|
|
32
|
-
const ext = extname(base);
|
|
33
|
-
const language = (ext === ".enpage" ? "en" : ext.substring(1)).toLowerCase();
|
|
34
|
-
logger.debug(`Found template readme file (${language}): ${basename(file)}`);
|
|
35
|
-
readme[language] = await readFile(file, "utf-8");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return config;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function loadConfigFromManifestFile(manifestPath: string, logger: Logger): SiteAndPagesConfig {
|
|
42
|
-
if (!fs.existsSync(manifestPath)) {
|
|
43
|
-
logger.error("🔴 No enpage.manifest.json found!\nYou may want to 'build' your template.\n\n");
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
return JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function validateTemplateConfig(config: SiteAndPagesConfig, logger: Logger) {
|
|
50
|
-
for (const key in config.site.datasources) {
|
|
51
|
-
if (config.site.datasources[key].provider === "http-json" && !config.site.datasources[key].sampleData) {
|
|
52
|
-
logger.error(
|
|
53
|
-
`🔴 Error: Datasource "${key}" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a "sampleData" key to your ${key} datasource.`,
|
|
54
|
-
);
|
|
55
|
-
throw new Error(`Missing sample data for datasource "${key}"`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Todo: replace validation from zod to ajv
|
|
60
|
-
// const validated = manifestSchema.safeParse(config.manifest);
|
|
61
|
-
// if (!validated.success) {
|
|
62
|
-
// logger.error(`🔴 Error: template manifest is invalid. Check your call to defineManifest().\n`);
|
|
63
|
-
// const err = fromError(validated.error);
|
|
64
|
-
// logger.error(`Hint: ${err.toString()}\n\n`);
|
|
65
|
-
// process.exit(1);
|
|
66
|
-
// }
|
|
67
|
-
|
|
68
|
-
return config;
|
|
69
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger as createLoggerBase,
|
|
3
|
-
type LogLevel,
|
|
4
|
-
type LogOptions,
|
|
5
|
-
type Logger as BaseLogger,
|
|
6
|
-
} from "vite";
|
|
7
|
-
// import { version } from "../../../package.json";
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
|
|
10
|
-
const VERSION = 0.1;
|
|
11
|
-
|
|
12
|
-
type UpstartLoggerLevel = LogLevel | "debug";
|
|
13
|
-
|
|
14
|
-
export function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {
|
|
15
|
-
// vite logger does not support "debug" level
|
|
16
|
-
const logger = createLoggerBase(level === "debug" ? "info" : level, {
|
|
17
|
-
prefix: "[upstart]",
|
|
18
|
-
allowClearScreen,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (showVersion) {
|
|
22
|
-
logger.info(chalk.hex("#7270c6").bold(`🚀 Upstart v${VERSION}\n`));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
...logger,
|
|
27
|
-
success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),
|
|
28
|
-
error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),
|
|
29
|
-
warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),
|
|
30
|
-
warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),
|
|
31
|
-
debug: (message: string, options?: LogOptions) => {
|
|
32
|
-
if (level === "debug") {
|
|
33
|
-
logger.info(chalk.gray(message), options);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const logger = createLogger();
|
|
40
|
-
|
|
41
|
-
export type Logger = BaseLogger & {
|
|
42
|
-
success: (message: string, options?: LogOptions) => void;
|
|
43
|
-
debug: (message: string, options?: LogOptions) => void;
|
|
44
|
-
};
|
package/src/shared/ajv.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import Ajv, { type ErrorObject } from "ajv";
|
|
2
|
-
import addFormats from "ajv-formats";
|
|
3
|
-
import { preset } from "./bricks/props/preset";
|
|
4
|
-
import { background, backgroundColor } from "./bricks/props/background";
|
|
5
|
-
import { containerLayout } from "./bricks/props/container";
|
|
6
|
-
import { basicAlign } from "./bricks/props/align";
|
|
7
|
-
import { hidden } from "./bricks/props/common";
|
|
8
|
-
import { border } from "./bricks/props/border";
|
|
9
|
-
import { padding } from "./bricks/props/padding";
|
|
10
|
-
import { image } from "./bricks/props/image";
|
|
11
|
-
import { color } from "./bricks/props/color";
|
|
12
|
-
import { shadow } from "./bricks/props/effects";
|
|
13
|
-
import { textContent } from "./bricks/props/text";
|
|
14
|
-
import { cssLength } from "./bricks/props/css-length";
|
|
15
|
-
import { urlOrPageId } from "./bricks/props/string";
|
|
16
|
-
|
|
17
|
-
export type { JSONSchemaType, AnySchemaObject, SchemaObject, JSONType } from "ajv";
|
|
18
|
-
|
|
19
|
-
export const ajv = new Ajv({
|
|
20
|
-
useDefaults: true,
|
|
21
|
-
strictSchema: false,
|
|
22
|
-
validateSchema: false,
|
|
23
|
-
coerceTypes: true,
|
|
24
|
-
allErrors: true,
|
|
25
|
-
inlineRefs: false,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
ajv.addSchema(preset(), "styles:preset");
|
|
29
|
-
ajv.addSchema(background(), "styles:background");
|
|
30
|
-
ajv.addSchema(backgroundColor(), "styles:backgroundColor");
|
|
31
|
-
ajv.addSchema(basicAlign(), "styles:basicAlign");
|
|
32
|
-
ajv.addSchema(containerLayout(), "styles:containerLayout");
|
|
33
|
-
ajv.addSchema(hidden(), "styles:hidden");
|
|
34
|
-
ajv.addSchema(border(), "styles:border");
|
|
35
|
-
ajv.addSchema(padding(), "styles:padding");
|
|
36
|
-
ajv.addSchema(color(), "styles:color");
|
|
37
|
-
ajv.addSchema(shadow(), "styles:shadow");
|
|
38
|
-
ajv.addSchema(cssLength(), "styles:cssLength");
|
|
39
|
-
ajv.addSchema(image(), "assets:image");
|
|
40
|
-
ajv.addSchema(textContent(), "content:textContent");
|
|
41
|
-
ajv.addSchema(urlOrPageId(), "content:urlOrPageId");
|
|
42
|
-
|
|
43
|
-
export const jsonStringsSupportedFormats = [
|
|
44
|
-
"date-time",
|
|
45
|
-
"time",
|
|
46
|
-
"date",
|
|
47
|
-
"email",
|
|
48
|
-
"hostname",
|
|
49
|
-
"ipv4",
|
|
50
|
-
"ipv6",
|
|
51
|
-
"uri",
|
|
52
|
-
"uri-reference",
|
|
53
|
-
"uuid",
|
|
54
|
-
"uri-template",
|
|
55
|
-
"json-pointer",
|
|
56
|
-
"relative-json-pointer",
|
|
57
|
-
"regex",
|
|
58
|
-
] as const;
|
|
59
|
-
|
|
60
|
-
// Add formats to Ajv
|
|
61
|
-
addFormats(ajv, [...jsonStringsSupportedFormats]);
|
|
62
|
-
|
|
63
|
-
ajv.addFormat("date-object", {
|
|
64
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
65
|
-
validate: (data: any) => data instanceof Date && !Number.isNaN(data.getTime()),
|
|
66
|
-
async: false,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
ajv.addFormat("richtext", {
|
|
70
|
-
validate: (data: string) => typeof data === "string",
|
|
71
|
-
async: false,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
ajv.addFormat("markdown", {
|
|
75
|
-
validate: (data: string) => typeof data === "string",
|
|
76
|
-
async: false,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
ajv.addFormat("multiline", {
|
|
80
|
-
validate: (data: string) => typeof data === "string",
|
|
81
|
-
async: false,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
ajv.addFormat("password", {
|
|
85
|
-
validate: (data: string) => typeof data === "string",
|
|
86
|
-
async: false,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export function serializeAjvErrors(errors: ErrorObject[] | null | undefined): string {
|
|
90
|
-
if (!errors || errors.length === 0) {
|
|
91
|
-
return "Unknown validation error";
|
|
92
|
-
}
|
|
93
|
-
return errors
|
|
94
|
-
.map((error) => {
|
|
95
|
-
const { instancePath, message, params } = error;
|
|
96
|
-
const path = instancePath || "root";
|
|
97
|
-
const details = Object.entries(params || {})
|
|
98
|
-
.map(([key, value]) => `${key}: ${value}`)
|
|
99
|
-
.join(", ");
|
|
100
|
-
return `${path} ${message} (${details})`;
|
|
101
|
-
})
|
|
102
|
-
.join("; ");
|
|
103
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function init() {
|
|
2
|
-
window.upstartQueue = window.upstartQueue || [];
|
|
3
|
-
document.addEventListener("visibilitychange", function logData() {
|
|
4
|
-
if (document.visibilityState === "hidden") {
|
|
5
|
-
const payload = JSON.stringify(window.upstartQueue);
|
|
6
|
-
if (navigator.sendBeacon?.(window.location.pathname, payload)) {
|
|
7
|
-
console.debug("beacon sent", payload);
|
|
8
|
-
window.upstartQueue = [];
|
|
9
|
-
} else {
|
|
10
|
-
console.debug("beacon failed", payload);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { BeaconPayload } from "./types";
|
|
2
|
-
|
|
3
|
-
export function track(type: BeaconPayload["e"], data: BeaconPayload["d"] = {}) {
|
|
4
|
-
const payload: BeaconPayload = {
|
|
5
|
-
e: type,
|
|
6
|
-
t: Date.now(),
|
|
7
|
-
d: data,
|
|
8
|
-
};
|
|
9
|
-
window.upstartQueue.push(payload);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
document.addEventListener(
|
|
13
|
-
"click",
|
|
14
|
-
function (e) {
|
|
15
|
-
const target = e.target as HTMLElement;
|
|
16
|
-
track("click", {
|
|
17
|
-
buttonId: target.id,
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
true,
|
|
21
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type EventType = "click" | "submit" | "custom";
|
|
2
|
-
|
|
3
|
-
export type BeaconPayload = {
|
|
4
|
-
e: EventType; // event type
|
|
5
|
-
t: number; // timestamp
|
|
6
|
-
d?: Record<string, unknown>; // data
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
interface Window {
|
|
11
|
-
upstartQueue: BeaconPayload[];
|
|
12
|
-
}
|
|
13
|
-
}
|