/*eslint-env es2020 */

let rows = [];
let workOrderRecordId;
for (let i = 1; i <= 500; i++) {
    let id = `${i}`;
    if (!workOrderRecordId) {
        // populate work order
        workOrderRecordId = `0WOx${'0'.repeat(11 - id.length)}${id}GAC`;
        rows.push([
            `UiApi::RecordRepresentation:${workOrderRecordId}`,
            JSON.stringify({
                apiName: 'WorkOrder',
                eTag: '',
                lastModifiedById: '005x0000000xNhqAAE',
                lastModifiedDate: '2018-06-08T20:20:23.000Z',
                systemModstamp: '2018-06-08T20:20:23.000Z',
                recordTypeId: null,
                recordTypeInfo: null,
                childRelationships: {},
                id: workOrderRecordId,
                weakEtag: 1528489223000,
                fields: {
                    Description: {
                        value: 'gohdttezdr wzotjohoxg',
                        displayValue: null,
                    },
                },
                links: {
                    Description: {
                        __ref: `UiApi::RecordRepresentation:${workOrderRecordId}__fields__Description`,
                    },
                },
            }),
            JSON.stringify({
                ingestionTimestamp: 1666930036148,
                expirationTimestamp: 1666930066148,
                representationName: 'RecordRepresentation',
                namespace: 'UiApi',
                version: '98c5b18512e48ca8d28727549507e4ba',
                metadataVersion: '0.111.0',
            }),
        ]);
    }
    // populate time sheet entry
    let timeSheetRecordId = `1tex${'0'.repeat(11 - id.length)}${id}AAA`;
    rows.push([
        `UiApi::RecordRepresentation:${timeSheetRecordId}`,
        JSON.stringify({
            apiName: 'TimeSheetEntry',
            eTag: '',
            lastModifiedById: '005x0000000xNhqAAE',
            lastModifiedDate: '2017-10-23T04:52:51.000Z',
            systemModstamp: '2017-10-23T04:52:51.000Z',
            recordTypeId: null,
            recordTypeInfo: null,
            childRelationships: {},
            id: timeSheetRecordId,
            weakEtag: 1508734371000,
            fields: {
                CreatedById: {
                    value: '005x0000000xNhqAAE',
                    displayValue: null,
                },
                CreatedDate: {
                    value: '2017-10-23T04:52:51.000Z',
                    displayValue: '10/22/2017 9:52 PM',
                },
                Description: {
                    value: 'zzwgyvtwyv odcecmlmoz',
                    displayValue: null,
                },
                DurationInMinutes: {
                    value: null,
                    displayValue: null,
                },
                EndTime: {
                    value: null,
                    displayValue: null,
                },
                IsDeleted: {
                    value: false,
                    displayValue: null,
                },
                IsLocked: {
                    value: false,
                    displayValue: null,
                },
                LastModifiedById: {
                    value: '005x0000000xNhqAAE',
                    displayValue: null,
                },
                LastModifiedDate: {
                    value: '2017-10-23T04:52:51.000Z',
                    displayValue: '10/22/2017 9:52 PM',
                },
                LastReferencedDate: {
                    value: null,
                    displayValue: null,
                },
                LastViewedDate: {
                    value: null,
                    displayValue: null,
                },
                LocationTimeZone: {
                    value: null,
                    displayValue: null,
                },
                MayEdit: {
                    value: true,
                    displayValue: null,
                },
                StartTime: {
                    value: null,
                    displayValue: null,
                },
                Status: {
                    value: 'New',
                    displayValue: 'New',
                },
                Subject: {
                    value: 'yuano dcehd',
                    displayValue: null,
                },
                SystemModstamp: {
                    value: '2017-10-23T04:52:51.000Z',
                    displayValue: '10/22/2017 9:52 PM',
                },
                TimeSheetEntryNumber: {
                    value: 'TSE-0005',
                    displayValue: null,
                },
                TimeSheetId: {
                    value: '1tsx00000000007AAA',
                    displayValue: null,
                },
                Type: {
                    value: 'Hours',
                    displayValue: 'Hours',
                },
                WorkOrderId: {
                    value: workOrderRecordId,
                    displayValue: null,
                },
                WorkOrderLineItemId: {
                    value: null,
                    displayValue: null,
                },
                WorkOrder: {
                    displayValue: id,
                    value: {
                        __ref: `UiApi::RecordRepresentation:${workOrderRecordId}`,
                    },
                },
            },
            links: {
                CreatedById: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__CreatedById`,
                },
                CreatedDate: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__CreatedDate`,
                },
                Description: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__Description`,
                },
                DurationInMinutes: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__DurationInMinutes`,
                },
                EndTime: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__EndTime`,
                },
                IsDeleted: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__IsDeleted`,
                },
                IsLocked: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__IsLocked`,
                },
                LastModifiedById: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__LastModifiedById`,
                },
                LastModifiedDate: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__LastModifiedDate`,
                },
                LastReferencedDate: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__LastReferencedDate`,
                },
                LastViewedDate: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__LastViewedDate`,
                },
                LocationTimeZone: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__LocationTimeZone`,
                },
                MayEdit: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__MayEdit`,
                },
                StartTime: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__StartTime`,
                },
                Status: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__Status`,
                },
                Subject: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__Subject`,
                },
                SystemModstamp: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__SystemModstamp`,
                },
                TimeSheetEntryNumber: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__TimeSheetEntryNumber`,
                },
                TimeSheetId: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__TimeSheetId`,
                },
                Type: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__Type`,
                },
                WorkOrderId: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__WorkOrderId`,
                },
                WorkOrderLineItemId: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__WorkOrderLineItemId`,
                },
                WorkOrder: {
                    __ref: `UiApi::RecordRepresentation:${timeSheetRecordId}__fields__WorkOrder`,
                },
            },
        }),
        JSON.stringify({
            ingestionTimestamp: 1666827317408,
            expirationTimestamp: 1666827347408,
            representationName: 'RecordRepresentation',
            namespace: 'UiApi',
            version: '98c5b18512e48ca8d28727549507e4ba',
            metadataVersion: '0.111.0',
        }),
    ]);
}

globalThis.__nimbus.plugins.LdsSqliteStore.batchOperations(
    [
        {
            type: 'upsert',
            keyColumn: 'key',
            table: 'lds_data',
            conflictColumns: ['key'],
            context: {},
            columns: ['key', 'data', 'metadata'],
            rows,
        },
    ],
    (_) => {}
);
