@feedmepos/mf-settings 0.0.76 → 0.0.77

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/app.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import "@feedmepos/mf-mdm";
2
+ import "@feedmepos/mf-media";
2
3
  import "@feedmepos/mf-order-setting";
3
- import { F, d, r as f } from "./app-5a16706e.js";
4
+ import { F as d, d as f, r as g } from "./app-aeaf5925.js";
4
5
  import "vue";
5
6
  import "@feedmepos/ui-library";
6
7
  import "vue-router";
7
8
  import "@feedmepos/mf-common";
8
9
  import "@feedmepos/mf-e-invoice";
9
10
  export {
10
- F as FmApp,
11
- d as i18nMessages,
12
- f as routers
11
+ d as FmApp,
12
+ f as i18nMessages,
13
+ g as routers
13
14
  };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * media-service client — upload and delete only.
3
+ *
4
+ * Docs: https://github.com/feedmepos/media-service/blob/main/docs/integration.md
5
+ *
6
+ * Settings stores plain photographs: no aspect-ratio variants, no AI. Every call
7
+ * here passes `aspectRatios: []`, which media-service reads as "store the original
8
+ * and queue nothing" — the billing precheck runs only when that list is non-empty,
9
+ * so these uploads cost the business nothing. Anything ratio- or AI-related lives
10
+ * in mf-menu's richer client (`apps/mf-menu/src/api/media.ts`); do not grow this one
11
+ * into a copy of it.
12
+ */
13
+ /**
14
+ * The four key segments identify an image: `{businessId}/{refType}/{refId}/{imageId}`.
15
+ * `refType` is caller-owned — the service takes whatever string it is given — so the
16
+ * values used here (`restaurant`, `business`) are ours to define.
17
+ *
18
+ * Segments are capped at 64 characters and must match `[A-Za-z0-9_.:-]+`; a Mongo id
19
+ * and the timestamps built in `mediaStorage` both satisfy that.
20
+ */
21
+ export interface MediaImageRef {
22
+ refType: string;
23
+ refId: string;
24
+ imageId: string;
25
+ }
26
+ export interface UploadIntentRes {
27
+ prefix: string;
28
+ objectKey: string;
29
+ uploadUrl: string;
30
+ method: string;
31
+ expiresAt: string;
32
+ }
33
+ export interface ConfirmRes {
34
+ prefix: string;
35
+ original: {
36
+ url: string;
37
+ width: number;
38
+ height: number;
39
+ };
40
+ }
41
+ export declare function currentBusinessId(): string;
42
+ export declare const mediaApi: {
43
+ uploadIntent(businessId: string, ref: MediaImageRef, file: File, restaurantId?: string): Promise<UploadIntentRes>;
44
+ /**
45
+ * Sends the bytes straight to object storage, so they never pass through a service
46
+ * pod. Deliberately a bare axios call: the signed URL must not carry our
47
+ * Authorization header, and `Content-Type` has to match what `uploadIntent` was told
48
+ * because the signature is bound to it.
49
+ */
50
+ putBytes(uploadUrl: string, file: File): Promise<void>;
51
+ confirm(businessId: string, ref: MediaImageRef, meta: {
52
+ width: number;
53
+ height: number;
54
+ fileName: string;
55
+ restaurantId?: string;
56
+ }): Promise<ConfirmRes>;
57
+ /**
58
+ * Deletes the whole set for one image id, original included.
59
+ *
60
+ * `aspectRatios: null` is what means "everything"; `[]` is rejected as a likely
61
+ * caller bug. Deleting something that no longer exists comes back as `not_found`,
62
+ * which the service counts as success, so this is safe to call twice.
63
+ */
64
+ deleteImage(businessId: string, ref: MediaImageRef): Promise<void>;
65
+ };
@@ -41,8 +41,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<im
41
41
  required: true;
42
42
  };
43
43
  }>> & Readonly<{}>, {
44
- initialValue: RestaurantDialogData;
45
44
  restaurantId: string;
45
+ initialValue: RestaurantDialogData;
46
46
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
47
47
  trigger?(_: {
48
48
  trigger: (restaurantId?: string | undefined, initialValue?: RestaurantDialogData | undefined) => void;
@@ -0,0 +1,51 @@
1
+ import { type MediaImageRef } from "@/api/media";
2
+ /**
3
+ * Photo storage for business and restaurant profiles, backed by media-service.
4
+ *
5
+ * Replaces the previous direct-to-R2 client, which had to ship an R2 access key and
6
+ * secret inside the production bundle to sign its own requests. Here the browser only
7
+ * ever holds a short-lived signed upload URL handed out by the service.
8
+ */
9
+ /** media-service rejects anything else with `415 UNSUPPORTED_MEDIA_TYPE`. */
10
+ export declare const SUPPORTED_MIME_TYPES: string[];
11
+ /**
12
+ * For `ImageDropField`. Narrower than the field's default because gif — which the old
13
+ * direct-to-R2 path accepted, since it validated nothing — cannot be stored here.
14
+ */
15
+ export declare const SUPPORTED_FILE_ACCEPT = ".jpg, .jpeg, .png, .webp";
16
+ export declare function isManagedUrl(url: string | null | undefined): boolean;
17
+ interface Scope {
18
+ businessId?: string;
19
+ restaurantId?: string;
20
+ }
21
+ export declare const mediaStorage: {
22
+ /**
23
+ * Uploads bytes and returns the URL to persist.
24
+ *
25
+ * Three calls: reserve a signed URL, PUT to it, then confirm so the asset row exists.
26
+ * A failure after the PUT leaves an orphaned object and no asset row, which is why
27
+ * `confirm` is never skipped.
28
+ */
29
+ upload(ref: MediaImageRef, file: File, options?: Scope & {
30
+ bustCache?: boolean;
31
+ }): Promise<string>;
32
+ /**
33
+ * Removes an image the merchant cleared.
34
+ *
35
+ * `currentUrl` is what the profile currently holds. Anything written before the
36
+ * media-service migration lives at a URL this API cannot address, so those objects
37
+ * are left in place and only the profile field is cleared by the caller — the images
38
+ * stay readable at their old URL either way, and no merchant-visible surface reads a
39
+ * profile field we did not clear.
40
+ */
41
+ remove(ref: MediaImageRef, currentUrl: string | null | undefined, options?: Scope): Promise<void>;
42
+ };
43
+ /**
44
+ * Carousel photos have no natural id, so they get a minted one.
45
+ *
46
+ * No colons or dots, unlike the ISO string the old key used: they are legal in a key
47
+ * segment today, but nothing here needs them and a plain alphanumeric stamp cannot be
48
+ * mangled by a URL encoder on the way to storage.
49
+ */
50
+ export declare function mintPhotoImageId(index: number): string;
51
+ export {};