File size: 5,972 Bytes
a9b29ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// DasuMae Doc -- in-browser sample document generator.
// Builds a small planted .docx using the core's own ZIP writer (Pkg/fflate), so
// a visitor without a dirty file sees the X-ray immediately. All content is
// obviously fictional. Runs through the same inspect() / scrub() flow as a real
// upload.

import { Pkg } from './ooxml.mjs';

const XD = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
const W = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
const R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
const PR = 'http://schemas.openxmlformats.org/package/2006/relationships';
const CT = 'http://schemas.openxmlformats.org/package/2006/content-types';

// Fictional sample content (clearly not real).
export const SAMPLE = {
  filename: 'sample-proposal.docx',
  creator: 'Pat Rivera',
  company: 'Nimbus Partners LLC (sample)',
  clientCode: 'NIMBUS-DEMO-2024',
  deleted: 'Our actual floor price is 30 percent lower than this quote.',
  comment: 'Do not send this version to the client.',
};

export function sampleDocxBytes() {
  const pkg = new Pkg();

  pkg.setText('[Content_Types].xml', XD
    + `<Types xmlns="${CT}">`
    + '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'
    + '<Default Extension="xml" ContentType="application/xml"/>'
    + '<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>'
    + '<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>'
    + '<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>'
    + '<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/>'
    + '<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>'
    + '<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>'
    + '<Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"/>'
    + '</Types>');

  pkg.setText('_rels/.rels', XD
    + `<Relationships xmlns="${PR}">`
    + `<Relationship Id="rIdDoc" Type="${R}/officeDocument" Target="word/document.xml"/>`
    + '<Relationship Id="rIdCore" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>'
    + `<Relationship Id="rIdApp" Type="${R}/extended-properties" Target="docProps/app.xml"/>`
    + `<Relationship Id="rIdCustom" Type="${R}/custom-properties" Target="docProps/custom.xml"/>`
    + '</Relationships>');

  pkg.setText('docProps/core.xml', XD
    + '<cp:coreProperties '
    + 'xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" '
    + 'xmlns:dc="http://purl.org/dc/elements/1.1/" '
    + 'xmlns:dcterms="http://purl.org/dc/terms/" '
    + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
    + `<dc:creator>${SAMPLE.creator}</dc:creator>`
    + `<cp:lastModifiedBy>${SAMPLE.creator}</cp:lastModifiedBy>`
    + '<cp:revision>4</cp:revision>'
    + '<dc:title>Draft proposal</dc:title>'
    + '<dcterms:created xsi:type="dcterms:W3CDTF">2026-02-10T08:00:00Z</dcterms:created>'
    + '<dcterms:modified xsi:type="dcterms:W3CDTF">2026-02-11T09:30:00Z</dcterms:modified>'
    + '</cp:coreProperties>');

  pkg.setText('docProps/app.xml', XD
    + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">'
    + `<Application></Application><Company>${SAMPLE.company}</Company>`
    + '</Properties>');

  pkg.setText('docProps/custom.xml', XD
    + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" '
    + 'xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">'
    + '<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="ClientCode">'
    + `<vt:lpwstr>${SAMPLE.clientCode}</vt:lpwstr></property></Properties>`);

  pkg.setText('word/styles.xml', XD
    + `<w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault/><w:pPrDefault/></w:docDefaults></w:styles>`);

  pkg.setText('word/settings.xml', XD
    + `<w:settings xmlns:w="${W}" xmlns:r="${R}">`
    + '<w:rsids><w:rsidRoot w:val="00C2A1B4"/><w:rsid w:val="00C2A1B4"/></w:rsids>'
    + '</w:settings>');

  pkg.setText('word/_rels/document.xml.rels', XD
    + `<Relationships xmlns="${PR}">`
    + `<Relationship Id="rIdStyles" Type="${R}/styles" Target="styles.xml"/>`
    + `<Relationship Id="rIdSettings" Type="${R}/settings" Target="settings.xml"/>`
    + `<Relationship Id="rIdComments" Type="${R}/comments" Target="comments.xml"/>`
    + '</Relationships>');

  pkg.setText('word/document.xml', XD
    + `<w:document xmlns:w="${W}" xmlns:r="${R}"><w:body>`
    + '<w:p><w:r><w:t>Nimbus Partners — Proposal (sample)</w:t></w:r></w:p>'
    + '<w:p>'
    + '<w:r><w:t xml:space="preserve">Thank you for the opportunity. </w:t></w:r>'
    + '<w:del w:id="1" w:author="Pat Rivera" w:date="2026-02-11T09:12:00Z">'
    + `<w:r><w:delText xml:space="preserve">${SAMPLE.deleted} </w:delText></w:r></w:del>`
    + '<w:commentRangeStart w:id="0"/>'
    + '<w:r><w:t>Our quoted price is final.</w:t></w:r>'
    + '<w:commentRangeEnd w:id="0"/>'
    + '<w:r><w:commentReference w:id="0"/></w:r>'
    + '</w:p>'
    + '<w:sectPr><w:pgSz w:w="12240" w:h="15840"/></w:sectPr>'
    + '</w:body></w:document>');

  pkg.setText('word/comments.xml', XD
    + `<w:comments xmlns:w="${W}">`
    + '<w:comment w:id="0" w:author="Pat Rivera" w:date="2026-02-11T09:15:00Z" w:initials="PR">'
    + `<w:p><w:r><w:t>${SAMPLE.comment}</w:t></w:r></w:p></w:comment></w:comments>`);

  return pkg.write();
}